Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
documentdb-util
Advanced tools
A little wrapper utility around document db to perform simple operations
Here are some examples on how to use this Utility. Note, await is only avaliable as an experimental feature in Node. Each function returns a promise, so you can simple chain promises instead of using await.
var DocumentDbUtility = require('documentdb-util');
var dbUtil = new DocumentDbUtility({authKey:'KEY', host:'URL TO DOCDB'}));
await dbUtil.database('test');
let collection = await dbUtil.collection(database, 'people');
let collections = await dbUtil.listCollections(database);
await dbUtil.insert(collection, {
name:'penguin',
profession: 'good guy'
});
let spec = {
query: 'Select * from c where c.name = @name',
parameters:[
{
name:'@name',
value: 'penguin'
}
]
}
let docs = await dbUtil.query(collection, spec);
let doc = (await dbUtil.query(collection, spec))[0];
doc.profession = "bad guy";
let docLink = dbUtil.createDocumentLink(database.id, collection.id, doc.id);
await dbUtil.update(docLink, doc);
let proc = {
id:"summer",
serverScript: function(a,b){
var context = getContext();
var response = context.getResponse();
let sum = a + b;
response.setBody(sum);
}
}
let procInstance = await dbUtil.createStoredProcedure(collection, proc);
let result = await dbUtil.executeStoredProcedure(procInstance,[1,2]);
let database = await dbUtil.database('test');
let collection = await dbUtil.collection(database, 'people');
let superTimeTrigger = {
id: "validateDocumentContents",
serverScript: function validate() {
var context = getContext();
var request = context.getRequest();
var documentToCreate = request.getBody();
var ts = new Date();
documentToCreate["supertime"] = ts.getTime();
request.setBody(documentToCreate);
},
triggerType: 'Pre',
triggerOperation: 'Create'
}
let triggerInstance = await dbUtil.trigger(collection, superTimeTrigger);
await dbUtil.insert(collection, {
name: 'penguin',
profession: 'better guy',
income: 200
}, { preTriggerInclude: [superTimeTrigger.id] });
var taxUdf = {
id: "tax",
serverScript: function tax(income) {
if (income == undefined)
throw 'no input';
if (income < 1000)
return income * 0.1;
else if (income < 10000)
return income * 0.2;
else
return income * 0.4;
}
}
let udf = await dbUtil.userDefinedFunction(collection, taxUdf);
await dbUtil.insert(collection, {
name: 'boomer',
profession: 'rich guy',
income: 10000
});
let spec2 = {
query: 'Select * from c WHERE udf.tax(c.income) > @taxAmount',
parameters: [
{
name: '@taxAmount',
value: 3000
}
]
}
let doc2 = await dbUtil.query(collection, spec2);
let docLink = dbUtil.createDocumentLink(database.id, collection.id, doc.id);
await dbUtil.delete(docLink);
await dbUtil.deleteDatabase('name');
await dbUtil.deleteCollection('dbName','collectionName');
FAQs
A little wrapper utility around document db to perform simple operations
The npm package documentdb-util receives a total of 1 weekly downloads. As such, documentdb-util popularity was classified as not popular.
We found that documentdb-util demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.