Skip to content

simon-p-r/sequelize-wrapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sequelize-wrapper

build status Windows Build status

Current Version dependency Status devDependency Status Coverage Status

Nodejs callback wrapper for Sequelize because using asCallback is error prone and every library should support callbacks as standard

Not currently fit for public consumption

API

new Manager(options);

options object must contain the following properties

  • dbOpts - object that can be passed to Sequelize module
  • dbs - object with keys being name of database to create or use, the value of object is an object with tables and dbOpts as property. The tables property defines the tables for relevant database and their schema whilst the dbOpts is the same as top level key encase you need to use a different database form the main declared one via an override.
Methods on constructor
.connect(schemas)
  • method to connect to database, callback has one param error if one occurred
.close(callback)
  • method to clean-up connection to database, as above callback has one param if an error occurs
Methods on properties of constructed object
  • .dbs[dbName].tables[modelName].find(options, cb); - callback wrapped for Sequelize findAll method
  • .dbs[dbName].tables[modelName].findById(options, cb); - callback wrapped for Sequelize findById method
  • .dbs[dbName].tables[modelName].findOne(options, cb); - callback wrapped for Sequelize findOne method
  • .dbs[dbName].tables[modelName].count(options, cb); - callback wrapped for Sequelize count method
  • .dbs[dbName].tables[modelName].insertOne(record, options, cb); - callback wrapped for Sequelize create method
  • .dbs[dbName].tables[modelName].insertMany(records, options, cb); - callback wrapped for Sequelize bulkCreate method
  • .dbs[dbName].tables[modelName].deleteMany(options, cb); - callback wrapped for Sequelize destroy method
  • .dbs[dbName].tables[modelName].deleteById(options, cb); - callback wrapped for Sequelize destroy method with where query for id set
  • .dbs[dbName].tables[modelName].updateMany(records, options, cb); - callback wrapped for Sequelize update method with where query for id set
  • .dbs[dbName].tables[modelName].drop(options, cb); - callback wrapped for Sequelize drop method, this will destroy the table completely

Todo

  • add tests
  • add CI with travis and appveyor
  • improve docs
  • clean up functionality
  • improve method validation

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published