Skip to content

Commit 9dc1014

Browse files
committedDec 7, 2023
bulk update nodes
1 parent b71e472 commit 9dc1014

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed
 

Diff for: ‎@types/index.d.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,8 @@ export declare interface NodeSession extends Session {
444444
findNodes(repository: TypedID|string, branch: TypedID|string, config: Object, pagination?: Pagination, callback?: ResultCb<Rows<Node>>): Promise<Rows<Node>>
445445
createNode(repository: TypedID|string, branch: TypedID|string, obj?: Object, options?: Object, callback?: ResultCb<Node>): Promise<Node>
446446
deleteNodes(repository: TypedID|string, branch: TypedID|string, nodes: string|Array<string>|Array<TypedID>, callback?: ResultCb<void>): Promise<void>
447-
447+
updateNodes(repository: TypedID|string, branch: TypedID|string, nodes: Array<TypedID>, callback?: ResultCb<void>): Promise<void>
448+
448449
queryNodeRelatives(repository: TypedID|string, branch: TypedID|string, node: TypedID|string, associationTypeQName: string, associationDirection: string, query?: Object, pagination?: Pagination, callback?: ResultCb<Rows<Node>>): Promise<Rows<Node>>
449450
queryNodeChildren(repository: TypedID|string, branch: TypedID|string, node: TypedID|string, query: Object, pagination?: Pagination, callback?: ResultCb<Rows<Node>>): Promise<Rows<Node>>
450451
listNodeAssociations(repository: TypedID|string, branch: TypedID|string, node: TypedID|string, associationType?: string, associationDirection?: string, pagination?: Pagination, callback?: ResultCb<Rows<Association>>): Promise<Rows<Association>>

Diff for: ‎src/session/default/methods/node.js

+13
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,19 @@ module.exports = function(Session)
367367
return this.put("/repositories/" + repositoryId + "/branches/" + branchId + "/nodes/" + nodeId, {}, node, callback);
368368
}
369369

370+
async updateNodes(repository, branch, nodes)
371+
{
372+
var repositoryId = this.acquireId(repository);
373+
var branchId = this.acquireId(branch);
374+
var callback = this.extractOptionalCallback(arguments);
375+
376+
var nodeEntries = await Promise.all(nodes.map(async node => [await this.buildNodeBranchReference(repositoryId, branchId, node), node]))
377+
var payload = {
378+
"nodes": Object.fromEntries(nodeEntries)
379+
};
380+
return this.put(`/repositories/${repositoryId}/branches/${branchId}/nodes`, {}, payload, callback);
381+
}
382+
370383
patchNode(repository, branch, node, patchObject)
371384
{
372385
var repositoryId = this.acquireId(repository);

0 commit comments

Comments
 (0)
Please sign in to comment.