2018-01-14 16:32:04 +00:00
|
|
|
import { Objectmap } from "lik";
|
|
|
|
import { DbTable } from "./smartdata.classes.dbtable";
|
|
|
|
export declare type TDocCreation = "db" | "new" | "mixed";
|
2017-07-15 22:11:03 +00:00
|
|
|
/**
|
|
|
|
* saveable - saveable decorator to be used on class properties
|
|
|
|
*/
|
|
|
|
export declare function svDb(): (target: DbDoc<any>, key: string) => void;
|
|
|
|
export declare class DbDoc<T> {
|
|
|
|
/**
|
|
|
|
* the collection object an Doc belongs to
|
|
|
|
*/
|
2018-01-07 17:10:16 +00:00
|
|
|
collection: DbTable<T>;
|
2017-07-15 22:11:03 +00:00
|
|
|
/**
|
|
|
|
* how the Doc in memory was created, may prove useful later.
|
|
|
|
*/
|
2018-01-12 00:22:58 +00:00
|
|
|
creationStatus: TDocCreation;
|
2017-07-15 22:11:03 +00:00
|
|
|
/**
|
|
|
|
* an array of saveable properties of a doc
|
|
|
|
*/
|
|
|
|
saveableProperties: string[];
|
|
|
|
/**
|
|
|
|
* name
|
|
|
|
*/
|
|
|
|
name: string;
|
2018-01-12 00:22:58 +00:00
|
|
|
/**
|
|
|
|
* primary id in the database
|
|
|
|
*/
|
|
|
|
dbId: string;
|
2017-07-15 22:11:03 +00:00
|
|
|
/**
|
|
|
|
* class constructor
|
|
|
|
*/
|
|
|
|
constructor();
|
2018-01-14 16:32:04 +00:00
|
|
|
static getInstances<T>(filterArg: any): Promise<T[]>;
|
2017-07-15 22:11:03 +00:00
|
|
|
/**
|
|
|
|
* saves this instance but not any connected items
|
|
|
|
* may lead to data inconsistencies, but is faster
|
|
|
|
*/
|
2018-01-12 00:22:58 +00:00
|
|
|
save(): Promise<void>;
|
2017-07-15 22:11:03 +00:00
|
|
|
/**
|
|
|
|
* also store any referenced objects to DB
|
|
|
|
* better for data consistency
|
|
|
|
*/
|
|
|
|
saveDeep(savedMapArg?: Objectmap<DbDoc<any>>): void;
|
2018-01-12 00:22:58 +00:00
|
|
|
createSavableObject(): any;
|
2017-07-15 22:11:03 +00:00
|
|
|
}
|