Skip to content

Instantly share code, notes, and snippets.

@ralyodio
Created May 31, 2015 08:10
Show Gist options
  • Save ralyodio/51fc190604a93b4061fa to your computer and use it in GitHub Desktop.
Save ralyodio/51fc190604a93b4061fa to your computer and use it in GitHub Desktop.
Thinky model definition
var cfg = require('../../config');
var thinky = require('thinky')(cfg.db);
var type = thinky.type;
var r = thinky.r;
// Create a model - the table is automatically created
var Thing = thinky.createModel("Thing", {
id: type.string(),
title: type.string(),
createdAt: type.date().default(() => {
return new Date();
}),
updatedAt: type.date().default(() => {
return new Date();
})
});
Thing.ensureIndex("createdAt");
Thing.allowExtra(false); //errors out
module.exports = Thing;
@neumino
Copy link

neumino commented May 31, 2015

var type = thinky.type;
var Thing = thinky.createModel("Thing", type.object({
  id: type.string(),
  title: type.string(),
  createdAt: type.date().default(() => {
    return new Date();
  }),
  updatedAt: type.date().default(() => {
    return new Date();
  })
}).allowExtra(false));

@ralyodio
Copy link
Author

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment