Created
May 31, 2015 08:10
-
-
Save ralyodio/51fc190604a93b4061fa to your computer and use it in GitHub Desktop.
Thinky model definition
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment