<commit_before>var cantina = require('cantina')
  , RedisCollection = require('../').RedisCollection;

var app = cantina.createApp();
app.use(require('../').plugin);
app.start(function() {
  var schema = {
    type: {
      type: 'string',
      index: true
    },
    timestamp: {
      type: 'object',
      default: new Date()
    }
  };
  var fruit = new RedisCollection({namespace: 'fruit', schema: schema, client: app.redis});
  fruit.create({type: 'apple', color: 'red'}, function(err, apple) {
    console.log(apple.id, 'id');
    console.log(apple.validate(), 'validate()');
    fruit.find({type: 'apple'}, {sort: 'timestamp', desc: true, limit: 5}, function(err, apples) {
      console.log(apples[0].properties, 'model found');
    });
  });
});<commit_msg>Update example<commit_after>var utils = require('cantina-utils')
  , RedisCollection = require('../').RedisCollection
  , RedisModel = require('../').RedisModel
  ;

function Fruit(attrs, options) {
  Fruit.super.call(this, attrs, options);
}
utils.inherits(Fruit, RedisModel);
Fruit.schema = {
  name: 'fruit',
  properties: {
    type: {
      type: 'string',
      index: true
    },
    timestamp: {
      type: 'object',
      default: function() { return new Date(); }
    }
  }
};
var fruit = new RedisCollection({model: Fruit, client: require('../').createClient()});
fruit.create({type: 'apple', color: 'red'}, function(err, apple) {
  console.log(apple.id, 'id');
  console.log(apple.validate(), 'validate()');
  fruit.find({type: 'apple'}, {sort: 'timestamp', desc: true, limit: 5}, function(err, apples) {
    console.log(apples[0].properties, 'model found');
  });
});
{'fraction_non_alphanumeric': 0.20072771376591875, 'fraction_numerical': 0.002425712553062462, 'mean_word_length': 3.76878612716763, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5174004', 'n_tokens_mistral': 545, 'n_tokens_neox': 537, 'n_words': 118}