Thinky

A light Node.js ORM for RethinkDB

Batteries included:

  • Schemas
  • All standard relations
  • Automatic creation of tables/indexes
  • And more!

Quickstart

Install via npm.

npm install thinky

Create models with schemas.

var thinky = require('thinky')();
var type = thinky.type;

// Create a model - the table is automatically created
var Post = thinky.createModel("Post", {
    id: type.string(),
    title: type.string(),
    content: type.string(),
    idAuthor: type.string()
}); 

var Author = thinky.createModel("Author", {
    id: type.string(),
    name: type.string()
});

// Join the models
Post.belongsTo(Author, "author", "idAuthor", "id");

Save a new post with its author.

// Create a new post
var post = new Post({
    title: "Hello World!",
    content: "This is an example."
});

// Create a new author
var author = new Author({
    name: "Michel"
});

// Join the documents
post.author = author;


post.saveAll().then(function(result) {
    /*
    post = result = {
        id: "0e4a6f6f-cc0c-4aa5-951a-fcfc480dd05a",
        title: "Hello World!",
        content: "This is an example.",
        idAuthor: "3851d8b4-5358-43f2-ba23-f4d481358901",
        author: {
            id: "3851d8b4-5358-43f2-ba23-f4d481358901",
            name: "Michel"
        }
    }
    */
});

And there is lot more! Here is a non exhaustive list:

You can learn more about thinky with these links: