Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
quantal-base-model
Advanced tools
# Quantal Base Model
A simple wrapper around bookshelf-modelbase. Unlike, bookshelf-modelbase,
quantal-base-model
will return Json objects by default. This behaviour can be controlled by the bConvertResultToJson
variable
which is passed to each method
NOTE
This module wraps the original bookshelf errors with quantal-errors. The reason being that it makes
handling certain errors easier e.g. (Collection.EmptyError
and Model.NotFoundError
are simply coerced to NotFoundError
)
npm install quantal-base-model
model.findOne
/**
* Returns a single instance of a model
* @param filter - the filter to pass fetch
* @param options {Object} - the options to pass to model.fetch
* @param {Boolean} [bConvertResultToJson=true] - if true, result will be converted to JSON, otherwise Bookself model instance will be returned
* @returns {Promise}
*/
findOne (filter, options, bConvertResultToJson = true)
model.create
/**
* Naive add - create and save a model based on data
* @param {Object} data
* @param {Object} options (optional)
* @param {Boolean} [bConvertResultToJson=true] - if true, result will be converted to JSON, otherwise Bookself model instance will be returned
* @return {Promise(bookshelf.Model)} single Model
*/
create (data, options, bConvertResultToJson = true)
model.destroy
/**
* Naive destroy
* @param {Object} options - The bookshelf destroy options
* @param options.id {Number|String} - The id of the model to be deleted
* @param {Boolean} [bConvertResultToJson=true] - if true, result will be converted to JSON, otherwise Bookself model instance will be returned
* @return {Promise(bookshelf.Model)} empty Model
*/
destroy (options, bConvertResultToJson = true)
model.findAll
/**
* Naive findAll - fetches all data for `this`
* @param {Object} filter - The filter/ query that will be applied to the find all query
* @param {Object} [options] - The bookshelf destroy options
* @param {Boolean} [bConvertResultToJson=true] - if true, result will be converted to JSON, otherwise Bookself model instance will be returned
* @return {Promise(bookshelf.Collection)} Bookshelf Collection of all Models
*/
findAll (filter, options, bConvertResultToJson = true)
model.findWhere
/**
* Naive findWhere - fetches all data for `this`. This method is an alias for findAll
* @param {Object} filter - The filter/ query that will be applied to the find all query
* @param {Object} options (optional)
* @param {Boolean} [bConvertResultToJson=true] - if true, result will be converted to JSON, otherwise Bookself model instance will be returned
* @return {Promise(bookshelf.Collection)} Bookshelf Collection of all Models
*/
findWhere (filter, options, bConvertResultToJson = true)
model.findById
/**
* Find a model based on it's ID
* @param {String | Number} id The model's ID
* @param {Object} [options] Options used of model.fetch
* @param {Boolean} [bConvertResultToJson=true] - if true, result will be converted to JSON, otherwise Bookself model instance will be returned
* @return {Promise(bookshelf.Model)}
*/
findById (id, options, bConvertResultToJson = true)
model.findOrCreate
/**
* Find or create - try and find the model, create one if not found
* @param {Object} data - The data to use to find a model. If The model does not exist, this data will be persisted
* @param {Object} options - The options thar are passed to fetch and create
* @param {Boolean} [bConvertResultToJson=true] - if true, result will be converted to JSON, otherwise Bookself model instance will be returned
* @return {Promise(bookshelf.Model)} single Model
*/
findOrCreate (data, options, bConvertResultToJson = true)
model.update
/**
* Naive update - update a model based on data
* @param {Object} data - The data to be used to update a model
* @param {Object} options - The options to pass to save
* @param {Boolean} [bConvertResultToJson=true] - if true, result will be converted to JSON, otherwise Bookself model instance will be returned
* @return {Promise(bookshelf.Model)} edited Model
*/
update (data, options, bConvertResultToJson = true)
model.upsert
/**
* Upsert - select a model based on data and update if found, insert if not found
* @param {Object} selectData - Data for select
* @param {Object} updateData - Data for update
* @param {Object} [options] options - for model.save
* @param {Boolean} [bConvertResultToJson=true] - if true, result will be converted to JSON, otherwise Bookself model instance will be returned
* @return {Promise(bookshelf.Model)} edited Model
*/
upsert (selectData, updateData, options, bConvertResultToJson = true)
MIT
FAQs
A simple wrapper aroud bookshelf-modelbase
We found that quantal-base-model demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.