Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
@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.
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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.