///
import { Connection } from "./connection";
import { Stream } from "./stream";
export declare enum CollectionType {
DOCUMENT_COLLECTION = 2,
EDGE_COLLECTION = 3
}
export type DocumentHandle = string | {
_key?: string;
_id?: string;
};
export type DocumentsHandle = {
_key: string;
_id?: string | undefined;
[key: string]: any;
};
export type IndexHandle = string | {
id?: string;
};
export interface ImportOptions {
type?: null | "auto" | "documents" | "array";
fromPrefix?: string;
toPrefix?: string;
overwrite?: boolean;
waitForSync?: boolean;
onDuplicate?: "error" | "update" | "replace" | "ignore";
complete?: boolean;
details?: boolean;
}
export interface ImportResult {
error: false;
created: number;
errors: number;
empty: number;
updated: number;
ignored: number;
details?: string[];
}
export interface CollectionUpdateProperties {
hasStream?: boolean;
waitForSync?: boolean;
}
export interface CollectionCreateProperties {
stream?: boolean;
waitForSync?: boolean;
isSystem?: boolean;
isLocal?: boolean;
}
export declare function isC8Collection(collection: any): collection is C8Collection;
export interface C8Collection {
isC8Collection: true;
name: string;
}
export declare const DOCUMENT_NOT_FOUND = 1202;
export declare const COLLECTION_NOT_FOUND = 1203;
export declare abstract class BaseCollection implements C8Collection {
isC8Collection: true;
name: string;
protected stream: Stream;
abstract type: CollectionType;
protected _idPrefix: string;
protected _connection: Connection;
constructor(connection: Connection, name: string);
protected _documentPath(documentHandle: DocumentHandle): string;
protected _documentHandle(documentHandle: DocumentHandle): string;
protected _indexHandle(indexHandle: IndexHandle): string;
protected _get(path: string, qs?: any): Promise;
protected _put(path: string, body: any): Promise;
setResultListener(callback: ((res: any) => void) | undefined): void;
get(): Promise;
exists(): Promise;
create(properties?: CollectionCreateProperties): Promise;
getInformation(): Promise;
getDocumentsNumber(): Promise;
getFigures(): Promise;
getMetadata(): Promise;
updateMetadata(properties: any): Promise;
getConnections(): Promise;
deleteConnection(connectionName: string): Promise;
onChange(dcName: string, subscriptionName?: string): Promise;
properties(): Promise;
count(): Promise;
rename(name: string): Promise;
truncate(): Promise;
truncateAndReload(): Promise;
drop(opts?: any): Promise;
updateCollectionProperties(properties: CollectionUpdateProperties): Promise;
documentExists(documentHandle: DocumentHandle): Promise;
document(documentHandle: DocumentHandle, graceful?: boolean): Promise;
replace(documentHandle: DocumentHandle, newValue: any, opts?: any): Promise;
replaceDocuments(documents: DocumentsHandle[], opts?: any): Promise;
update(documentHandle: DocumentHandle, newValue: any, opts?: any): Promise;
updateDocuments(documents: DocumentsHandle[], opts?: any): Promise;
remove(documentHandle: DocumentHandle, opts?: any): Promise;
removeDocuments(documents: string[] | DocumentsHandle[], opts?: any): Promise;
import(data: Buffer | Blob | string | any[], { type, ...opts }?: ImportOptions): Promise;
indexes(): Promise;
index(indexName: string): Promise;
createIndex(details: any): Promise;
dropIndex(indexName: string): Promise;
createCapConstraint(opts?: any): Promise;
createHashIndex(fields: string[] | string, opts?: any): Promise;
createSkipList(fields: string[] | string, opts?: any): Promise;
createPersistentIndex(fields: string[] | string, opts?: any): Promise;
createGeoIndex(fields: string[] | string, opts?: any): Promise;
createFulltextIndex(fields: string[] | string, opts?: any): Promise;
createTtlIndex(fields: string[] | string, expireAfter: number, name?: string): Promise;
}
export interface DocumentSaveOptions {
waitForSync?: boolean;
returnNew?: boolean;
returnOld?: boolean;
overwrite?: boolean;
silent?: boolean;
}
export declare class DocumentCollection extends BaseCollection {
type: CollectionType;
constructor(connection: Connection, name: string);
save(data: any, opts?: DocumentSaveOptions | boolean): Promise;
}
export declare class EdgeCollection extends BaseCollection {
type: CollectionType;
constructor(connection: Connection, name: string);
protected _documentPath(documentHandle: DocumentHandle): string;
edge(documentHandle: DocumentHandle, graceful?: boolean): Promise;
save(data: any, opts?: DocumentSaveOptions | boolean): Promise;
save(data: any, fromId: DocumentHandle, toId: DocumentHandle, opts?: DocumentSaveOptions | boolean): Promise;
protected _edges(documentHandle: DocumentHandle, direction: any): Promise;
edges(vertex: DocumentHandle): Promise;
inEdges(vertex: DocumentHandle): Promise;
outEdges(vertex: DocumentHandle): Promise;
}
export declare function constructCollection(connection: Connection, data: any): DocumentCollection;
//# sourceMappingURL=collection.d.ts.map