@marcoleo/asset-manager
Asset Manager Corso NodeJS
Last updated 5 years ago by marcobnz .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @marcoleo/asset-manager 
SYNC missed versions from official npm registry.

#asset-manager

A node.js module for NodeJS Avanscoperta Course. This module handles the insert and update of an Asset in a mongodb istance.

npm install marcoleo/asset-manager

Usage

var asset_manager = require('asset-manager')(dbname,collectionname)
asset_manager.put({name: 'prova', status: 'status'}, function (err, result) {
      console.log(result)
      });

Methods

put

A method to insert an Asset in a Mongo database.

function(obj, cb){
	if(obj._id){
		obj._id = "";
	}
	
	var result = Joi.validate(obj, schema)

	if(result.error != null)
		return cb(result.error,null);
		asset.findAndModify({
		    query: mongojs.ObjectId(obj._id) ,
		    update: { $set: obj },
		    new: true,
		    upsert:true
		}, function(err, doc, lastErrorObject) {
		    cb(err,doc);
		});
	}

get

A method to update an Asset in a Mongo database.

	function(query,cb){
		if(query == null || query === undefined)
			return cb({error:"Must Provide a query"},null);
		
		asset.findOne(query,cb);
	}

close

A method to close the connection to Mongo database.

	function(){
		db.close();
	}

Dependencies

Joi for validation
mongojs for database connection
mocha for testing

Current Tags

  • 1.0.7                                ...           latest (5 years ago)

13 Versions

  • 1.0.7                                ...           5 years ago
  • 1.0.6                                ...           5 years ago
  • 1.0.5                                ...           5 years ago
  • 1.0.4                                ...           5 years ago
  • 1.0.3                                ...           5 years ago
  • 1.0.2                                ...           5 years ago
  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
  • 0.0.5                                ...           5 years ago
  • 0.0.4                                ...           5 years ago
  • 0.0.3                                ...           5 years ago
  • 0.0.2                                ...           5 years ago
  • 0.0.1                                ...           5 years ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (5)
Dev Dependencies (2)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |