Generic Database API Framework
DBHouse is a generic database API framework, it makes developer to be able to access any kinds of database via generic API. API was designed like SQL Syntax and easy-use.
* Currently, DBHouse only supports MongoDB with official driver (node-mongodb-native).
Using NPM to install DBHouse module directly:
npm install dbhouse
DBHouse is really easy to use, some topic you might be interested, see below:
Peform a simple query and return only one record.
var DBHouse = ;/* Create connection with MongoDB */var dbHouse = ;dbHouse;
DBHouse attempts to implement Object/Relation Mapping(ORM), you can define own database scheme with DBHouse APIs.
var DBHouse = ;/* Create connection with database server */var dbHouse = ;/* Define schema */var Contact =_id: type: 'UUID'name: type: 'String'email: type: 'String'tel: type: 'String'created: type: 'Date';dbHouse;
* DBHouse will generate UUID automatically for "_id" field if you set field type to "UUID".
With ORM mechanism of DBHouse, it can just use
DBHouse.Index to create indexes for specific fields in database.
var DBHouse = ;/* Define schema */var Contact =_id: type: 'UUID'name: type: 'String'email: type: 'String'tel: type: 'String'created: type: 'Date';/* Create Indexes */var index =fields: 'created'fields: 'name' 'created';/* Create connection with database server */var dbHouse = ;dbHouse;
Sets specific database as the default (current) database.
Note that DBHouse always attempts to keep connection alive for more queries next time, it means that open() doesn't re-create a new connection every time if connection is still alive.
Sets specific collection(table) as current collection(table).
Same function with collection(), it is just another name for developer who is familar with SQL.
Select the content of columns(fields) from a database.
Select the condition for filtering records.
Find records with specific field:
var DBHouse = ;// Create connection with MongoDBvar dbHouse = ;dbHouse;
Licensed under the MIT License.
Copyright© 2012 Fred Chien <email@example.com>