npm.io
1.0.0 • Published 8 years ago

version-repo-mongo

Licence
MIT
Version
1.0.0
Deps
4
Size
2.6 MB
Vulns
0
Weekly
0

An extention to the version-repo package with a backend provided by MongoDB.

See version-repo for the general version-repo API.

Repositories Classes

MongoRepo (API: Asynchronous, Stored Types: Any)

A synchronous repository which keeps resources in memory.

Constructor parameters

  • collection: A MongoDB Collection object.

  • config: An object with the following attributes:

    • update: (optional) one of "latest" (default), "any", "none"
    • delete: (optional) one of "latest" (default), "any", "none"
Example:
var MongoClient = require("mongodb").MongoClient;
var MongoRepo = require("version-repo-node").MongoRepo;

MongoClient.connect(
	"mongodb://localhost:27017",
	(err, client) => {
		if (err) 
			throw err;

		var DBO = client.db("mydb");

		DBO.createCollection(
			"my-repo", 
			function(err, collection) {

				if (err) 
					throw err;

				my_repo = new MongoRepo(collection);
			});
	});

Keywords