Skip to content

Instantly share code, notes, and snippets.

@chovy chovy/model.js
Created May 31, 2015

Embed
What would you like to do?
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

This comment has been minimized.

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));
@chovy

This comment has been minimized.

Copy link
Owner Author

chovy commented May 31, 2015

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.