Skip to content

Instantly share code, notes, and snippets.

@mulderp
Created March 24, 2014 13:40
Show Gist options
  • Select an option

  • Save mulderp/9740253 to your computer and use it in GitHub Desktop.

Select an option

Save mulderp/9740253 to your computer and use it in GitHub Desktop.

Revisions

  1. mulderp created this gist Mar 24, 2014.
    41 changes: 41 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,41 @@
    global.serverbone = require("serverbone");
    global.BaseModel = serverbone.models.BaseModel;
    global.redis = require("redis");
    global.RedisDb = require('backbone-db-redis');
    global.store = new RedisDb('mymodel', redis.createClient());


    global.movieSchema = {
    id: 'schemas/movies',
    type: 'object',
    properties: {
    title: {
    type: 'string'
    },
    length: {
    type: 'integer'
    }
    // genres --> Array ?
    },
    indexes: [{
    property: 'title'
    }]
    };


    global.MovieModel = BaseModel.extend({
    type: 'moviesmodel',
    schema: movieSchema,
    sync: RedisDb.sync.bind(redis),
    db: redis,
    url: function() {
    var key = this.dbBaseKey || this.type;
    if (this.isNew()) {
    return key;
    } else {
    return key + ':' + this.get(this.idAttribute);
    }
    }
    });

    var repl = require("repl").start({ useGlobal: true, ignoreUndefined: false })