@awhere/api
Version:
The awesome aWhere API for JavaScript.
58 lines (57 loc) • 2.01 kB
TypeScript
import { DatabaseItemType } from '@awhere/interfaces';
import { ReadWriteAdapter } from './DbAdapter';
import { DbWatcher } from '../DbWatcher';
import FieldDefinition from '../FieldDefinition';
import { ISchemaDefinition, ISchemaTypeOpts } from '../SchemaDefinition';
export interface IStructuredCollectionProps {
schemaDefinition: ISchemaDefinition;
queryDefinition?: any;
attachment?: IAttachmentInfos;
relations?: IRelationInfos;
}
export default class StructuredCollection extends ReadWriteAdapter {
static systemSchema: ISchemaDefinition;
static generateDocumentId: () => string;
static generateHistoryDocumentId: () => string;
static generateAttachmentId: () => string;
get type(): import("@awhere/interfaces").ItemTypeChildren.databaseItem;
protected readonly _subtype: DatabaseItemType;
get subtype(): DatabaseItemType;
protected _props: IStructuredCollectionProps;
get props(): IStructuredCollectionProps;
set props(value: IStructuredCollectionProps);
protected nameIndexes: any;
getFieldByName(fieldName: string): FieldDefinition | undefined;
getField(id: string): FieldDefinition;
moveField(source: FieldDefinition, target: FieldDefinition): ISchemaDefinition;
addField(field: FieldDefinition | {
_id?: string;
name: string;
type: string;
props?: ISchemaTypeOpts<any>;
}): ISchemaDefinition;
updateField(field: FieldDefinition | {
_id?: string;
name: string;
type: string;
props?: ISchemaTypeOpts<any>;
}): ISchemaDefinition;
deleteField(field: FieldDefinition | string): ISchemaDefinition;
watchDb(): Promise<DbWatcher>;
}
interface IAttachmentInfos {
[key: string]: IAttachmentInfo;
}
interface IAttachmentInfo {
fileSize: number;
fileType: string;
}
interface IRelationInfos {
[key: string]: IRelationInfo;
}
interface IRelationInfo {
ref: string;
foreignField: string;
descriptionField: string;
}
export {};