mvom
Version:
Multivalue Object Mapper
28 lines (27 loc) • 1.32 kB
TypeScript
import Document from '../Document';
import type { ForeignKeyDbDefinition } from '../ForeignKeyDbTransformer';
import type Schema from '../Schema';
import type { MvRecord } from '../types';
import BaseSchemaType from './BaseSchemaType';
/** A Document Array Schema Type */
declare class DocumentArrayType<TSchema extends Schema> extends BaseSchemaType {
/** An instance of Schema representing the document structure of the array's contents */
private readonly valueSchema;
constructor(valueSchema: TSchema);
/**
* Cast to array of documents
* @throws {@link TypeError} Throws if a non-null/non-object is passed
*/
cast(value: unknown): Document<TSchema>[];
/** Get value from mv data */
get(record: MvRecord): Document<TSchema>[];
/** Set specified document array value into mv record */
set(originalRecord: MvRecord, documents: Document<TSchema>[]): MvRecord;
/** Validate the document array */
validate(documentList: Document<TSchema>[]): Map<string, string[]>;
/** Create an array of foreign key definitions that will be validated before save */
transformForeignKeyDefinitionsToDb(documentList: Document<TSchema>[]): ForeignKeyDbDefinition[];
/** Generate subdocument instances */
private makeSubDocument;
}
export default DocumentArrayType;