Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

backbone-db-redis

Package Overview
Dependencies
Maintainers
2
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

backbone-db-redis

Redis driver for Backbone.Db

  • 0.1.2
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
2
Weekly downloads
 
Created
Source

Usage

Build Status


var store = new RedisDb('mymodel', redis.createClient());

var MyModel = Model.extend({
  db: store,
  sync: RedisDb.sync,
  url: function() {
    var key = 'mymodel';
    if(!this.isNew()) {
      key += ':' + this.id;
    }
    return key;
  }
});

var a = new MyModel({id:"1"});

a.fetch().done(function(model) {
  console.log(a);
});

Indexing:

Model can define Array typed property "indexes", which defines which attributes are indexed. Example:

var MyModel = Model.extend({
  indexes: [
    {
      property: 'value', 
      sort: 'asc'
    },
    {
      property: 'id',
      sort: function() {
        return Date.now();
      },
      dependencies: [
        {
          // add to index if attribute "featured" is set to true
          attribute: 'featured',
          value: true
        }
      ],
      key: 'z:mymodels:featured'
    }
  ]
});

property

Model's attribute to be indexed

sort

If defined attribute index is stored in sorted set. If defined as function, score will be calculated with given function. If not defined attribute is indexed in unordered set.

dependencies

Index attribute only if defined dependencies are met.

key

If defined, store index in given set key, otherwise created automatically.

FAQs

Package last updated on 20 Mar 2015

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc