
Research
Security News
Malicious PyPI Package Exploits Deezer API for Coordinated Music Piracy
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
leveldb-backbone-adapter
Advanced tools
This is a backend for backbone, to have storage in LevelDB
This is a library to run BackboneJs Models and Collection on Nodejs with persistance to LevelDb(Using sublevel for each collection).
npm install leveldb-backbone-adapter
var Backbone = require('Backbone'),
levelDbBackboneAdapter = require('leveldb-backbone-adapter');
levelDbBackboneAdapter(Backbone, {
db : 'testDb'
});
This will modify Backbone.sync method to work with sublevel persistance for regular Backbone fetch and save functions. Also levelDbBackboneAdapter will add more functions to have query capabilities against our collection.
This will make all Backbone Models and Collections to have a _db that is the sublevel for the collection, its also available for each instance of you models and collections.
var ExampleModel = Backbone.Model.extend({
dbName : 'example'
});
var ExampleCollection = Backbone.Collection.extend({
dbName : 'example',
model : ExampleModel
});
This way the collection and the model will have persistance to the sublevel example. You can have as many collections and models, each pointing to a diferent sublevel.
All this api is for Collections instances, so the first step is
var exampleCollection = new ExampleCollection();
Note: Collection Api is heavy focus on promises.
Will get all items in the sublevel.
var q = exampleCollection.fetch();
q.then(function () {
// Do something once the collection is loaded.
});
Will get all items that match an object or a function.
var q = exampleCollection.fetchFilter(function(item){
return !item.active;
});
q.then(function () {
// Do something once the collection is loaded.
});
Or
var q = exampleCollection.fetchFilter({active:false});
This will fetch one element from the sublevel.
var q = exampleCollection.fetchOne(function(item){
return !item.active;
});
q.then(function (model) {
// Do something with the model
});
Note: Model is not added to the collection.
Note: Model Api works with promises and callbacks.
Will get a model by key from the data base and return it as a model.
ExampleModel.get(key, function(err, model){
// Do something with the model.
});
or
var q = ExampleModel.get(data.get('id'));
q.then(function(model){
// Do something with the model.
});
Will get a model that matches the object or function suplied as query. It will throw a error if you have more than one element matching the query.
With callback:
ExampleModel.find({name:'some name'}, function(err, model){
// Do something with the model.
});
or
ExampleModel.find(function(data){
return data.name === 'somename';
},function(err,model){
// Do something with the model.
});
With promise
var q = ExampleModel.find({name:'Aaron Rodgers'});
q.then(function (model) {
// Do something with the model.
});
or
var q = ExampleModel.find(function(data){
return data.name === 'somename';
});
q.then(function(model){
// Do something with the model.
});
With promise:
var model = new ExampleModel({/* Some data */});
var q = model.save();
q.then(function(model){
// Do something with the model.
});
With callback[Not that clean]:
var model = new ExampleModel({/* Some data */});
var fn = function(){
// Do something with the model.
}
model.save(null, {success:fn});
model.save('attr', value, {success: function (/* model */) {
// Do something with the model.
} } );
or
model.set('active', true);
var q = model.save();
q.then(function(model){
// Do something with the model.
});
Note: to handle errors with a promise use:
q.then(function(model){
// Do something with the model.
}).fail(function(err){
// Handle error.
});
or just handle errors with
q.fail(function(err){
// Handle error.
});
You could make a generic error handler and pass it to all you promises.
FAQs
This is a backend for backbone, to have storage in LevelDB
We found that leveldb-backbone-adapter 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
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.
Security News
Newly introduced telemetry in devenv 1.4 sparked a backlash over privacy concerns, leading to the removal of its AI-powered feature after strong community pushback.