Skip to content

Commit 4d7e5ef

Browse files
committed
Fix replaceByExample/updateByExample
1 parent 2d4f47d commit 4d7e5ef

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ This driver uses semantic versioning:
2222

2323
- Fixed empty query results containing `[undefined]` ([#687](https://github.com/arangodb/arangojs/issues/683))
2424

25+
- Fixed `updateByExample` and `replaceByExample` new value parameter name
26+
27+
Note that these methods are still deprecated. Previously the `newValue`
28+
parameter was incorrectly called `newData`, which prevented the methods from
29+
working at all.
30+
2531
## [7.0.1] - 2020-08-21
2632

2733
This is a maintenance release because the initial v7 release did not include

src/collection.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2175,7 +2175,7 @@ export interface DocumentCollection<T extends object = any>
21752175
* Replaces all documents in the collection matching the given example.
21762176
*
21772177
* @param example - An object representing an example for the documents.
2178-
* @param newData - Document data to replace the matching documents with.
2178+
* @param newValue - Document data to replace the matching documents with.
21792179
* @param options - Options for replacing the documents.
21802180
*
21812181
* @deprecated Simple Queries have been deprecated in ArangoDB 3.4 and can be
@@ -2185,16 +2185,16 @@ export interface DocumentCollection<T extends object = any>
21852185
* ```js
21862186
* const db = new Database();
21872187
* const collection = db.collection("some-collection");
2188-
* const newData = { flavor: "chocolate" };
2188+
* const newValue = { flavor: "chocolate" };
21892189
* // const { replaced } = await collection.replaceByExample(
21902190
* // { flavor: "strawberry" },
2191-
* // newData
2191+
* // newValue
21922192
* // );
21932193
* const cursor = await db.query(aql`
21942194
* RETURN LENGTH(
21952195
* FOR doc IN ${collection}
21962196
* FILTER doc.flavor == "strawberry"
2197-
* REPLACE doc WITH ${newData} IN ${collection}
2197+
* REPLACE doc WITH ${newValue} IN ${collection}
21982198
* RETURN 1
21992199
* )
22002200
* `);
@@ -2203,15 +2203,15 @@ export interface DocumentCollection<T extends object = any>
22032203
*/
22042204
replaceByExample(
22052205
example: Partial<DocumentData<T>>,
2206-
newData: DocumentData<T>,
2206+
newValue: DocumentData<T>,
22072207
options?: SimpleQueryReplaceByExampleOptions
22082208
): Promise<ArangoResponseMetadata & SimpleQueryReplaceByExampleResult>;
22092209

22102210
/**
22112211
* Updates all documents in the collection matching the given example.
22122212
*
22132213
* @param example - An object representing an example for the documents.
2214-
* @param newData - Document data to update the matching documents with.
2214+
* @param newValue - Document data to update the matching documents with.
22152215
* @param options - Options for updating the documents.
22162216
*
22172217
* @deprecated Simple Queries have been deprecated in ArangoDB 3.4 and can be
@@ -2224,13 +2224,13 @@ export interface DocumentCollection<T extends object = any>
22242224
* const newData = { color: "red" };
22252225
* // const { updated } = await collection.updateByExample(
22262226
* // { flavor: "strawberry" },
2227-
* // newData
2227+
* // newValue
22282228
* // );
22292229
* const cursor = await db.query(aql`
22302230
* RETURN LENGTH(
22312231
* FOR doc IN ${collection}
22322232
* FILTER doc.flavor == "strawberry"
2233-
* UPDATE doc WITH ${newData} IN ${collection}
2233+
* UPDATE doc WITH ${newValue} IN ${collection}
22342234
* RETURN 1
22352235
* )
22362236
* `);
@@ -2239,7 +2239,7 @@ export interface DocumentCollection<T extends object = any>
22392239
*/
22402240
updateByExample(
22412241
example: Partial<DocumentData<T>>,
2242-
newData: Patch<DocumentData<T>>,
2242+
newValue: Patch<DocumentData<T>>,
22432243
options?: SimpleQueryUpdateByExampleOptions
22442244
): Promise<ArangoResponseMetadata & SimpleQueryUpdateByExampleResult>;
22452245

@@ -3756,7 +3756,7 @@ export class Collection<T extends object = any>
37563756

37573757
replaceByExample(
37583758
example: Partial<DocumentData<T>>,
3759-
newData: DocumentData<T>,
3759+
newValue: DocumentData<T>,
37603760
options?: SimpleQueryReplaceByExampleOptions
37613761
) {
37623762
return this._db.request(
@@ -3766,7 +3766,7 @@ export class Collection<T extends object = any>
37663766
body: {
37673767
...options,
37683768
example,
3769-
newData,
3769+
newValue,
37703770
collection: this._name,
37713771
},
37723772
},
@@ -3776,7 +3776,7 @@ export class Collection<T extends object = any>
37763776

37773777
updateByExample(
37783778
example: Partial<DocumentData<T>>,
3779-
newData: Patch<DocumentData<T>>,
3779+
newValue: Patch<DocumentData<T>>,
37803780
options?: SimpleQueryUpdateByExampleOptions
37813781
) {
37823782
return this._db.request(
@@ -3786,7 +3786,7 @@ export class Collection<T extends object = any>
37863786
body: {
37873787
...options,
37883788
example,
3789-
newData,
3789+
newValue,
37903790
collection: this._name,
37913791
},
37923792
},

0 commit comments

Comments
 (0)