0.1.0 • Published 5 years ago
mongo-nested-sets v0.1.0
mongo-nested-sets
Mongo nested sets realisation. Based on code from ivansglazunov metre repository.
Install
npm i mongo-nested-sets
Tests
Tests can be started with comand export MONGO_URL="yourMongoUrl" && npm install && npm run retest
in work catalog.
For more information lern
src/tests/index.js
Example
npm style
import { MongoClient } from 'mongodb';
import { NestedSets } from 'mongo-nested-sets';
const ns = new NestedSets();
MongoClient.connect(process.env.MONGO_URL,{ useNewUrlParser: true }, function(err, client) {
ns.init({
collection: client.db('yourDB').collection('yourCollection'),
field: "yourField",
client,
});
//do everything;
});
meteor style
import { Meteor } from 'meteor/meteor';
import { NestedSets } from 'mongo-nested-sets';
const ns = new NestedSets();
ns.init({
collection: Meteor["yourCollection"].rawCollection(),
field: "yourField",
client: Meteor["yourCollection"]._driver.mongo.client,
});
//do everything;