@@ -153,6 +153,34 @@ export type ValidationLevel = "none" | "new" | "moderate" | "strict";
153153 */
154154export type WriteOperation = "insert" | "update" | "replace" ;
155155
156+ /**
157+ * Represents a bulk operation failure for an individual document.
158+ */
159+ export type DocumentOperationFailure = {
160+ /**
161+ * Indicates that the operation failed.
162+ */
163+ error : true ;
164+ /**
165+ * Human-readable description of the failure.
166+ */
167+ errorMessage : string ;
168+ /**
169+ * Numeric representation of the failure.
170+ */
171+ errorNum : number ;
172+ } ;
173+
174+ /**
175+ * Metadata returned by a document operation.
176+ */
177+ export type DocumentOperationMetadata = DocumentMetadata & {
178+ /**
179+ * Revision of the document that was updated or replaced by this operation.
180+ */
181+ _oldRev ?: string ;
182+ } ;
183+
156184/**
157185 * Properties defining a computed value.
158186 */
@@ -1855,7 +1883,9 @@ export interface DocumentCollection<T extends Record<string, any> = any>
18551883 save (
18561884 data : DocumentData < T > ,
18571885 options ?: CollectionInsertOptions
1858- ) : Promise < DocumentMetadata & { new ?: Document < T > } > ;
1886+ ) : Promise <
1887+ DocumentOperationMetadata & { new ?: Document < T > ; old ?: Document < T > }
1888+ > ;
18591889 /**
18601890 * Inserts new documents with the given `data` into the collection.
18611891 *
@@ -1880,7 +1910,12 @@ export interface DocumentCollection<T extends Record<string, any> = any>
18801910 saveAll (
18811911 data : Array < DocumentData < T > > ,
18821912 options ?: CollectionInsertOptions
1883- ) : Promise < Array < DocumentMetadata & { new ?: Document < T > } > > ;
1913+ ) : Promise <
1914+ Array <
1915+ | ( DocumentOperationMetadata & { new ?: Document < T > ; old ?: Document < T > } )
1916+ | DocumentOperationFailure
1917+ >
1918+ > ;
18841919 /**
18851920 * Replaces an existing document in the collection.
18861921 *
@@ -1909,7 +1944,9 @@ export interface DocumentCollection<T extends Record<string, any> = any>
19091944 selector : DocumentSelector ,
19101945 newData : DocumentData < T > ,
19111946 options ?: CollectionReplaceOptions
1912- ) : Promise < DocumentMetadata & { new ?: Document < T > ; old ?: Document < T > } > ;
1947+ ) : Promise <
1948+ DocumentOperationMetadata & { new ?: Document < T > ; old ?: Document < T > }
1949+ > ;
19131950 /**
19141951 * Replaces existing documents in the collection, identified by the `_key` or
19151952 * `_id` of each document.
@@ -1938,7 +1975,10 @@ export interface DocumentCollection<T extends Record<string, any> = any>
19381975 newData : Array < DocumentData < T > & ( { _key : string } | { _id : string } ) > ,
19391976 options ?: Omit < CollectionReplaceOptions , "ifMatch" >
19401977 ) : Promise <
1941- Array < DocumentMetadata & { new ?: Document < T > ; old ?: Document < T > } >
1978+ Array <
1979+ | ( DocumentOperationMetadata & { new ?: Document < T > ; old ?: Document < T > } )
1980+ | DocumentOperationFailure
1981+ >
19421982 > ;
19431983 /**
19441984 * Updates an existing document in the collection.
@@ -1968,7 +2008,9 @@ export interface DocumentCollection<T extends Record<string, any> = any>
19682008 selector : DocumentSelector ,
19692009 newData : Patch < DocumentData < T > > ,
19702010 options ?: CollectionUpdateOptions
1971- ) : Promise < DocumentMetadata & { new ?: Document < T > ; old ?: Document < T > } > ;
2011+ ) : Promise <
2012+ DocumentOperationMetadata & { new ?: Document < T > ; old ?: Document < T > }
2013+ > ;
19722014 /**
19732015 * Updates existing documents in the collection, identified by the `_key` or
19742016 * `_id` of each document.
@@ -1999,7 +2041,10 @@ export interface DocumentCollection<T extends Record<string, any> = any>
19992041 > ,
20002042 options ?: Omit < CollectionUpdateOptions , "ifMatch" >
20012043 ) : Promise <
2002- Array < DocumentMetadata & { new ?: Document < T > ; old ?: Document < T > } >
2044+ Array <
2045+ | ( DocumentOperationMetadata & { new ?: Document < T > ; old ?: Document < T > } )
2046+ | DocumentOperationFailure
2047+ >
20032048 > ;
20042049 /**
20052050 * Removes an existing document from the collection.
@@ -2053,7 +2098,9 @@ export interface DocumentCollection<T extends Record<string, any> = any>
20532098 removeAll (
20542099 selectors : ( string | ObjectWithKey ) [ ] ,
20552100 options ?: Omit < CollectionRemoveOptions , "ifMatch" >
2056- ) : Promise < Array < DocumentMetadata & { old ?: Document < T > } > > ;
2101+ ) : Promise <
2102+ Array < ( DocumentMetadata & { old ?: Document < T > } ) | DocumentOperationFailure >
2103+ > ;
20572104 /**
20582105 * Bulk imports the given `data` into the collection.
20592106 *
@@ -2829,7 +2876,7 @@ export interface EdgeCollection<T extends Record<string, any> = any>
28292876 save (
28302877 data : EdgeData < T > ,
28312878 options ?: CollectionInsertOptions
2832- ) : Promise < DocumentMetadata & { new ?: Edge < T > } > ;
2879+ ) : Promise < DocumentOperationMetadata & { new ?: Edge < T > ; old ?: Edge < T > } > ;
28332880 /**
28342881 * Inserts new documents with the given `data` into the collection.
28352882 *
@@ -2852,7 +2899,12 @@ export interface EdgeCollection<T extends Record<string, any> = any>
28522899 saveAll (
28532900 data : Array < EdgeData < T > > ,
28542901 options ?: CollectionInsertOptions
2855- ) : Promise < Array < DocumentMetadata & { new ?: Edge < T > } > > ;
2902+ ) : Promise <
2903+ Array <
2904+ | ( DocumentOperationMetadata & { new ?: Edge < T > ; old ?: Edge < T > } )
2905+ | DocumentOperationFailure
2906+ >
2907+ > ;
28562908 /**
28572909 * Replaces an existing document in the collection.
28582910 *
@@ -2889,7 +2941,7 @@ export interface EdgeCollection<T extends Record<string, any> = any>
28892941 selector : DocumentSelector ,
28902942 newData : DocumentData < T > ,
28912943 options ?: CollectionReplaceOptions
2892- ) : Promise < DocumentMetadata & { new ?: Edge < T > ; old ?: Edge < T > } > ;
2944+ ) : Promise < DocumentOperationMetadata & { new ?: Edge < T > ; old ?: Edge < T > } > ;
28932945 /**
28942946 * Replaces existing documents in the collection, identified by the `_key` or
28952947 * `_id` of each document.
@@ -2933,7 +2985,12 @@ export interface EdgeCollection<T extends Record<string, any> = any>
29332985 replaceAll (
29342986 newData : Array < DocumentData < T > & ( { _key : string } | { _id : string } ) > ,
29352987 options ?: CollectionReplaceOptions
2936- ) : Promise < Array < DocumentMetadata & { new ?: Edge < T > ; old ?: Edge < T > } > > ;
2988+ ) : Promise <
2989+ Array <
2990+ | ( DocumentOperationMetadata & { new ?: Edge < T > ; old ?: Edge < T > } )
2991+ | DocumentOperationFailure
2992+ >
2993+ > ;
29372994 /**
29382995 * Updates an existing document in the collection.
29392996 *
@@ -2970,7 +3027,7 @@ export interface EdgeCollection<T extends Record<string, any> = any>
29703027 selector : DocumentSelector ,
29713028 newData : Patch < DocumentData < T > > ,
29723029 options ?: CollectionUpdateOptions
2973- ) : Promise < DocumentMetadata & { new ?: Edge < T > ; old ?: Edge < T > } > ;
3030+ ) : Promise < DocumentOperationMetadata & { new ?: Edge < T > ; old ?: Edge < T > } > ;
29743031 /**
29753032 * Updates existing documents in the collection, identified by the `_key` or
29763033 * `_id` of each document.
@@ -3014,7 +3071,12 @@ export interface EdgeCollection<T extends Record<string, any> = any>
30143071 Patch < DocumentData < T > > & ( { _key : string } | { _id : string } )
30153072 > ,
30163073 options ?: CollectionUpdateOptions
3017- ) : Promise < Array < DocumentMetadata & { new ?: Edge < T > ; old ?: Edge < T > } > > ;
3074+ ) : Promise <
3075+ Array <
3076+ | ( DocumentOperationMetadata & { new ?: Edge < T > ; old ?: Edge < T > } )
3077+ | DocumentOperationFailure
3078+ >
3079+ > ;
30183080 /**
30193081 * Removes an existing document from the collection.
30203082 *
@@ -3059,7 +3121,9 @@ export interface EdgeCollection<T extends Record<string, any> = any>
30593121 removeAll (
30603122 selectors : DocumentSelector [ ] ,
30613123 options ?: CollectionRemoveOptions
3062- ) : Promise < Array < DocumentMetadata & { old ?: Edge < T > } > > ;
3124+ ) : Promise <
3125+ Array < ( DocumentMetadata & { old ?: Edge < T > } ) | DocumentOperationFailure >
3126+ > ;
30633127 /**
30643128 * Bulk imports the given `data` into the collection.
30653129 *
0 commit comments