Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@c8/base-model
Advanced tools
A base model for all bookshelf-based models on our database layer.
A base model for all bookshelf-based models on our database layer.
'createdDate'
and 'lastUpdatedDate'
timestamps to the Model (this can be changed by setting hasTimestamps
to false
);delAttribute
);findAll
, findById
, insert
, removeById
, updateById
);
remove
does not hard-delete, instead it sets the is_deleted
column to true
(this behaviour can be changed by
overriding the function or by setting delAttribute
to false);NOTE: BaseMode assumes you're using the awesome bookshelf-camelcase
plugin. If you're not, just set hasTimestamps: ['created_date', 'last_updated_date']
and delAttribute: 'is_deleted'
npm install @c8/base-model
BaseModel
requires you to pass in an initialized instance of bookshelf, like in the example below:
const bookshelf = require('bookshelf')(db)
const BaseModel = require('../lib/index')(bookshelf)
const MyModel = BaseModel.extend({
tableName: 'my_table' // needs to have created_date, last_updated_date and is_deleted columns
})
module.exports = bookshelf.model('MyModel', MyModel)
findAll(opts)
@param {object} [opts]
An optional options object@param {boolean} [opts.includeRemoved]
Find removed items as well@returns {Promise.<Array>}
A Promise resolving to the fetched entries array.findById(id, opts)
@param {number} id
- The ID of the entry to get.@param {object} [opts]
An optional options object@param {boolean} [opts.includeRemoved]
Find removed items as well@returns {Promise.<Object>}
A promise resolving to the fetched entry.@throws {NotFoundError}
An entry with the given id
must exist.findWhere(where, opts)
@param {number} where
- The criteria to be met.@param {object} [opts]
- An optional options object.@param {boolean} [opts.includeRemoved]
- Find removed items as well.@returns {Promise.<Array>}
- A promise resolving to the fetched entries array.insert(obj)
@param {object} obj
- The object to be created.@returns {Promise.<Object>}
A Promise resolving to the newly created entry.removeById(id)
@param {number} id
- The entry ID.@returns {Promise.<Object>}
A Promise resolving to the destroyed entry.@throws {NotFoundError}
A Campaign with the given id
must exist.updateById(id, entry, opts)
@param {number} id
- The ID of the Campaign to update.@param {object} entry
- The Campaign object to update.@param {object} [opts]
An optional options object@param {boolean} [opts.includeRemoved]
Find removed items as well@returns {Promise.<Object>}
A Promise resolving to the updated entry fields.@throws {TypeError}
entry.id
must exist and be integer.@throws {NotFoundError}
An entry with the given entry.id
must exist.FAQs
A base model for all bookshelf-based models on our database layer.
The npm package @c8/base-model receives a total of 5 weekly downloads. As such, @c8/base-model popularity was classified as not popular.
We found that @c8/base-model demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.