documentdb-typescript
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -205,5 +205,15 @@ "use strict"; | ||
// lower consistency modes) | ||
let tryReload = (callback) => this.database.client.log("Reading document " + docURI) && | ||
let tryReadDoc = (callback) => this.database.client.log("Reading document " + docURI) && | ||
this.database.client.documentClient.readDocument(docURI, options, callback); | ||
return yield Util_1.curryPromise(tryReload, this.database.client.timeout, maxRetries, undefined, true)(); | ||
let result = yield Util_1.curryPromise(tryReadDoc, this.database.client.timeout, maxRetries, undefined, true)(); | ||
if (typeof obj !== "string" && !obj._self) { | ||
// check that other properties match, too | ||
for (var prop in obj) { | ||
if (Object.prototype.hasOwnProperty.call(obj, prop)) { | ||
if (obj[prop] !== result[prop]) | ||
throw new Error("Resource not found"); | ||
} | ||
} | ||
} | ||
return result; | ||
} | ||
@@ -210,0 +220,0 @@ else if (typeof obj === "string") { |
{ | ||
"name": "documentdb-typescript", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "TypeScript API for Microsoft Azure DocumentDB", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -48,3 +48,3 @@ import * as _DocumentDB from "./_DocumentDB"; | ||
}, maxRetries?: number, options?: AllOptions): Promise<ResultT & _DocumentDB.DocumentResource>; | ||
/** Find the document with the same `id` property as given object, or the latest document with exactly the same values for all given properties if `id` is not set */ | ||
/** Find the document with exactly the same values for all properties (i.e. where _all_ own properties of the given object match exactly) */ | ||
findDocumentAsync<ResultT extends {}>(obj: Partial<ResultT>, maxRetries?: number, options?: AllOptions): Promise<ResultT & _DocumentDB.DocumentResource>; | ||
@@ -65,3 +65,3 @@ /** Check if a document with given ID exists (without reading the document) */ | ||
deleteDocumentAsync(id: string, maxRetries?: number, options?: AllOptions): Promise<void>; | ||
/** Delete the given document (must have a `_self` property, e.g. the result of `storeDocumentAsync` or `findDocumentAsync`, OR a valid `id` property) */ | ||
/** Delete the given document (must have a `_self` property, e.g. the result of `storeDocumentAsync` or `findDocumentAsync`, OR a valid `id` property, note that other properties are NOT matched against the document to be deleted) */ | ||
deleteDocumentAsync(doc: { | ||
@@ -68,0 +68,0 @@ _self: string; |
82605
1280