1 | import { Model } from "./Model";
|
2 | import { Schema } from "./Schema";
|
3 | import { DynamoDB, AWSError } from "aws-sdk";
|
4 | import { CallbackType, ObjectType } from "./General";
|
5 | import { SerializerOptions } from "./Serializer";
|
6 | import { PopulateSettings } from "./Populate";
|
7 | export interface DocumentSaveSettings {
|
8 | overwrite?: boolean;
|
9 | return?: "request" | "document";
|
10 | }
|
11 | export interface DocumentSettings {
|
12 | type?: "fromDynamo" | "toDynamo";
|
13 | }
|
14 | export declare class Document {
|
15 | constructor(model: Model<Document>, object?: DynamoDB.AttributeMap | ObjectType, settings?: DocumentSettings);
|
16 | model?: Model<Document>;
|
17 | static objectToDynamo(object: ObjectType): DynamoDB.AttributeMap;
|
18 | static objectToDynamo(object: any, settings: {
|
19 | type: "value";
|
20 | }): DynamoDB.AttributeValue;
|
21 | static objectToDynamo(object: ObjectType, settings: {
|
22 | type: "object";
|
23 | }): DynamoDB.AttributeMap;
|
24 | static fromDynamo(object: DynamoDB.AttributeMap): ObjectType;
|
25 | static isDynamoObject(object: ObjectType, recurrsive?: boolean): boolean | null;
|
26 | static attributesWithSchema: (document: Document, model: Model<Document>) => Promise<string[]>;
|
27 | static objectFromSchema: (object: any, model: Model<Document>, settings?: DocumentObjectFromSchemaSettings) => Promise<any>;
|
28 | static prepareForObjectFromSchema: (object: any, model: Model<Document>, settings: DocumentObjectFromSchemaSettings) => any;
|
29 | conformToSchema: (this: Document, settings?: DocumentObjectFromSchemaSettings) => Promise<Document>;
|
30 | toDynamo: (this: Document, settings?: Partial<DocumentObjectFromSchemaSettings>) => Promise<any>;
|
31 | prepareForResponse(): Promise<Document>;
|
32 | original(): ObjectType | null;
|
33 | toJSON(): ObjectType;
|
34 | serialize(nameOrOptions?: SerializerOptions | string): ObjectType;
|
35 | delete(this: Document): Promise<void>;
|
36 | delete(this: Document, callback: CallbackType<void, AWSError>): void;
|
37 | save(this: Document): Promise<Document>;
|
38 | save(this: Document, callback: CallbackType<Document, AWSError>): void;
|
39 | save(this: Document, settings: DocumentSaveSettings & {
|
40 | return: "request";
|
41 | }): Promise<DynamoDB.PutItemInput>;
|
42 | save(this: Document, settings: DocumentSaveSettings & {
|
43 | return: "request";
|
44 | }, callback: CallbackType<DynamoDB.PutItemInput, AWSError>): void;
|
45 | save(this: Document, settings: DocumentSaveSettings & {
|
46 | return: "document";
|
47 | }): Promise<Document>;
|
48 | save(this: Document, settings: DocumentSaveSettings & {
|
49 | return: "document";
|
50 | }, callback: CallbackType<Document, AWSError>): void;
|
51 | populate(): Promise<Document>;
|
52 | populate(callback: CallbackType<Document, AWSError>): void;
|
53 | populate(settings: PopulateSettings): Promise<Document>;
|
54 | populate(settings: PopulateSettings, callback: CallbackType<Document, AWSError>): void;
|
55 | }
|
56 | export interface DocumentObjectFromSchemaSettings {
|
57 | type: "toDynamo" | "fromDynamo";
|
58 | schema?: Schema;
|
59 | checkExpiredItem?: boolean;
|
60 | saveUnknown?: boolean;
|
61 | defaults?: boolean;
|
62 | forceDefault?: boolean;
|
63 | customTypesDynamo?: boolean;
|
64 | validate?: boolean;
|
65 | required?: boolean | "nested";
|
66 | enum?: boolean;
|
67 | populate?: boolean;
|
68 | combine?: boolean;
|
69 | modifiers?: ("set" | "get")[];
|
70 | updateTimestamps?: boolean | {
|
71 | updatedAt?: boolean;
|
72 | createdAt?: boolean;
|
73 | };
|
74 | }
|