🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

fhdb-collection

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fhdb-collection

Collection based wrapper for the FeedHenry database API to facilitate ease of use.

latest
Source
npmnpm
Version
0.1.1
Version published
Maintainers
1
Created
Source

fh-db Collection

Simple wrapper around the $fh.db API to allow the creation of Models to represent data objects.

Example Usage

Create a Collection wrapper.


var Collection = require('fhdb-collection'),
	util = require('util');

function People () {
	Collection.call(this, 'People');
}
util.inherits(People, Collection);

People.prototype.customMethod = function () {
	// Do something!
};

module.exports = new People('people');

Use it with the inherited methods!

var People = require('./People');

People.create({
	name: 'john',
	age: '23'
}, function (err, res) {
	// Receives the usual fh-db callback results
});

Class Functions

Any class that inherits from this receives the following functions. Which correspond to $fh.db functions.

  • create (data, callback)
  • update (guid, data, callback)
  • read (guid, callback)
  • remove (guid, callback)
  • truncate (callback)
  • find ([opts,] callback)
  • findOne ([opts,] callback)
  • findBy (property, value, callback)

Contributing

We could make this module more flexible to support models etc so you could do the following:

// Item.js inherits from our Model class
var Item = require('./Item.js');

var i = new Item({
	type: 'car',
	condition: 'great'
});


i.save(function(err) {
	if (err) {
		// It didn't save...
	}
});

FAQs

Package last updated on 18 Feb 2015

Did you know?

Socket

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.

Install

Related posts