ravendb
Version:
RavenDB client for Node.js
73 lines • 3.31 kB
TypeScript
import { FieldIndexing, FieldStorage, FieldTermVector } from "./Enums.js";
import { MetadataObject } from "../Session/MetadataObject.js";
import { AttachmentName, IAttachmentObject } from "../Attachments/index.js";
import { CapitalizeType } from "../../Types/index.js";
import { FieldVectorOptions } from "../Queries/VectorSearch/VectorSearchOptions.js";
export type IndexingMapDefinition<TInput, TOutput> = (document: TInput) => TOutput | TOutput[];
export type IndexingReduceDefinition<TItem> = (result: IndexingGroupResults<TItem>) => IndexingMapReduceFormatter<TItem>;
type KeySelector<TDocument, TKey> = (document: TDocument) => TKey;
export interface CreateFieldOptions {
storage?: boolean;
indexing?: FieldIndexing;
termVector?: FieldTermVector;
vector?: FieldVectorOptions;
}
export interface IndexingMapUtils {
load<T = any>(documentId: string, collection: string): T;
cmpxchg<T = any>(key: string): T;
getMetadata(document: any): MetadataObject;
id(document: any): string;
createSpatialField(wkt: string): SpatialField;
createSpatialField(lat: number, lng: number): SpatialField;
createField(name: string, value: any, options: CreateFieldOptions): void;
attachmentsFor(document: any): CapitalizeType<AttachmentName>[];
loadAttachment(document: any, attachmentName: string): IAttachmentObject;
loadAttachments(document: any): IAttachmentObject[];
noTracking: NoTrackingUtils;
}
export interface NoTrackingUtils {
load<T = any>(documentId: string, collection: string): T;
}
export declare class StubMapUtils<T> implements IndexingMapUtils {
load: <T>(documentId: string, collection: string) => T;
cmpxchg: <T = any>(key: string) => T;
getMetadata: (document: any) => MetadataObject;
id: (document: any) => string;
createSpatialField: (wktOrLat: string | number, lng?: number) => void;
createField: (name: string, value: any, options?: CreateFieldOptions) => void;
attachmentsFor: (document: any) => CapitalizeType<AttachmentName>[];
loadAttachment: (document: any, attachmentName: string) => IAttachmentObject;
loadAttachments: (document: any) => IAttachmentObject[];
noTracking: NoTrackingUtils;
}
interface Group<TDocument, TKey> {
key: TKey;
values: TDocument[];
}
export declare class IndexingGroupResults<TDocument> {
groupBy<TKey>(selector: KeySelector<TDocument, TKey>): TKey extends void ? never : IndexingReduceResults<TDocument, TKey>;
}
export declare class IndexingReduceResults<TDocument, TKey> {
private _group;
constructor(selector: KeySelector<TDocument, TKey>);
aggregate(reducer: IndexingMapDefinition<Group<TDocument, TKey>, TDocument>): IndexingMapReduceFormatter<TDocument>;
}
export declare class IndexingMapReduceFormatter<TDocument> {
private _groupBy;
private _aggregate;
constructor(groupBy: KeySelector<TDocument, any>, aggregate: IndexingMapDefinition<Group<TDocument, any>, any>);
format(): string;
}
export type CreatedFieldOptions = {
storage?: FieldStorage | boolean;
indexing?: FieldIndexing;
termVector?: FieldTermVector;
};
export type CreatedField = {
$value: any;
$name: string;
$options: CreatedFieldOptions;
};
export type SpatialField = void;
export {};
//# sourceMappingURL=StronglyTyped.d.ts.map