Skip to content

Instantly share code, notes, and snippets.

View RienNeVaPlus's full-sized avatar
🔌
Plugged in

RienNeVaPlus RienNeVaPlus

🔌
Plugged in
View GitHub Profile
@RienNeVaPlus
RienNeVaPlus / collection.bulkUpsert.ts
Last active August 7, 2019 14:03
🥑 ArangoDB: Adds the much needed `collection.bulkUpsert` function to ArangoJS. Uses a single query instead of multiple expensive roundtrips.
import { Database, DocumentCollection } from 'arangojs'
const db = new Database(process.env.ARANGODB_URL);
db.useDatabase('name');
/**
* Upserts (merges) the content of the documents with the given documents and
* optionally returns an array containing the documents’ metadata.
*
* @param {string|ArangoDB.Collection} collection - collection to use
* @param {Document[]} documents - list of documents to upsert