
Research
/Security News
Malicious npm Packages Target WhatsApp Developers with Remote Kill Switch
Two npm packages masquerading as WhatsApp developer libraries include a kill switch that deletes all files if the phone number isn’t whitelisted.
bookshelf-committed-plugin
Advanced tools
A plugin for Bookshelf ORM to fire the `committed` event when a model is `saved` inside a transaction and after the transaction has successfully committed
A plugin for Bookshelf ORM to fire the committed
event on saved
and transaction completed successfully.
saved
: insert
or update
The bookshelf created
, saved
, updated
events actually fire before the transaction completes. So if you're using a transaction, and you try to load the model or related models in the on
handler, the models wont be loaded.
initialize(){
this.on('committed', (model, attrs, options, previousAttributes) => {
// do something
});
}
model: Bookshelf.Model,
attrs: Object, // plain object of attributes that will be updated
options: Object, // options passed to save, including method which is automatically added if not originally in save options
previousAttributes: Object, // plain object of attributes prior to this save, (not neccessarily the same as prior to the transaction)
Bookshelf.plugin(require('bookshelf-committed-plugin'));
If I do a save on a model twice in the same transaction, will committed
event be fired twice?
Yes
Why did you include previousAttributes when bookshelf supports this via model.previousAttributes() and other bookshelf event handlers don't have this parameter?
Bookshelf's previousAttributes()
is unreliable because its conceivable that the value gets overwritten by another save
, before we retrieve the value in the on
handler of the other save
. Additionally with the case of multiple save
s on the same model in the same transaction, the first previousAttributes
will be overwritten by the time the committed
events get called. Additionally it makes more sense to me to call the event handler with this value as an additional argument rather than storing it in the model itself, as its only relevant immediately post save
.
FAQs
A plugin for Bookshelf ORM to fire the `committed` event when a model is `saved` inside a transaction and after the transaction has successfully committed
The npm package bookshelf-committed-plugin receives a total of 1 weekly downloads. As such, bookshelf-committed-plugin popularity was classified as not popular.
We found that bookshelf-committed-plugin 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.
Research
/Security News
Two npm packages masquerading as WhatsApp developer libraries include a kill switch that deletes all files if the phone number isn’t whitelisted.
Research
/Security News
Socket uncovered 11 malicious Go packages using obfuscated loaders to fetch and execute second-stage payloads via C2 domains.
Security News
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.