make filterObjectsByStringEntries and checkDoesObjectMatchReference work with FileContent
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
import { DATA_VERSION, ValidObject } from "../Utility/typeSafety";
|
||||
import {
|
||||
HandlerManager,
|
||||
StringEntryObject,
|
||||
createTimestamp,
|
||||
parseValidObject,
|
||||
stringify,
|
||||
@@ -175,7 +176,7 @@ export enum FileModelSubPath {
|
||||
};
|
||||
|
||||
// types
|
||||
export interface FileContent<T extends string> extends ValidObject {
|
||||
export interface FileContent<T extends string> extends ValidObject, StringEntryObject {
|
||||
fileId: string;
|
||||
fileContentId: string;
|
||||
creationDate: string;
|
||||
|
||||
@@ -29,7 +29,8 @@ export class HandlerManager<T> {
|
||||
}
|
||||
|
||||
// objects
|
||||
export type StringEntryObject = { [key: string]: string };
|
||||
export type StringEntryObject = { [key: string]: string | undefined };
|
||||
|
||||
export function filterObjectsByStringEntries<T>(
|
||||
reference: StringEntryObject,
|
||||
converter: (T) => StringEntryObject,
|
||||
@@ -56,7 +57,10 @@ export function checkDoesObjectMatchReference<T>(
|
||||
reference
|
||||
)) {
|
||||
const [referenceKey, referenceValue] = referenceEntry;
|
||||
const stringEntryObjectValue: string = stringEntryObject[referenceKey];
|
||||
const stringEntryObjectValue: string | undefined =
|
||||
stringEntryObject[referenceKey];
|
||||
|
||||
if (referenceValue == undefined) return false;
|
||||
|
||||
if (referenceValue[0] == "-") {
|
||||
const strippedReferenceValue: string = referenceValue.substring(1);
|
||||
@@ -102,7 +106,7 @@ export function collectObjectValuesForKey<T>(
|
||||
|
||||
for (const object of objects) {
|
||||
const stringEntryObject: StringEntryObject = converter(object);
|
||||
const stringEntryObjectValue: string = stringEntryObject[key];
|
||||
const stringEntryObjectValue: string | undefined = stringEntryObject[key];
|
||||
if (stringEntryObjectValue == undefined || stringEntryObjectValue == "")
|
||||
continue;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user