- Documentation
- Quickstart
- Introduction
- Importing thinky
- Schemas
- Relations
- Virtuals
- Feeds
- FAQ
- API
-
- Model
- - getTableName
- - define
- - defineStatic
- - ensureIndex
- - hasOne
- - belongsTo
- - hasMany
- - hasAndBelongsToMany
- - save
- - pre
- - post
- - Query's methods
- - EventEmitter's methods
- - EventEmitter's methods
for documents
- Document
- - getModel
- - merge
- - validate
- - validateAll
- - save
- - saveAll
- - getOldValue
- - isSaved
- - setSaved
- - delete
- - deleteAll
- - purge
- - addRelation
- - removeRelation
- - getFeed
- - closeFeed
- - EventEmitter's methods
- Query
- - getJoin
- - addRelation
- - removeRelation
- - run
- - execute
- - ReQL methods
- - Overwritten ReQL methods
FAQ
What version of RethinkDB supports?
Thinky currently requires RethinkDB >=1.12 to work. A 1.x
version relies on
rethinkdbdash 1.x
and RethinkDB 1.x
.
Thinky uses merge
with an anonymous function under the hood to perform joins and this feature was shipped only in 1.12.
https://github.com/rethinkdb/rethinkdb/issues/1345.
How do I migrate from v0.2?
There is no easy way to migrate. The whole API changed. The changes include:
- lazy execution of a query
- different relations (the previous
hasOne
is nowbelongsTo
- to follow Active Record models) null
can be accepted if the optionenforce_type
is set to"loose"
I sincerely apologize for breaking the API, but given the feedback I got, these changes were necessary.
Help?
No SLA, but a few developers may be able to help there:
What is the difference with Reheat?
That is actually a tough question. I personally haven’t really use Reheat, but the main difference is probably about the syntax. Reheat’s syntax is closer to MongoDB’s one.
A few more differences:
- All the connections are automatically managed in thinky.
- More relations are available in thinky.
If you have used both ORMs, I would love to hear from your experience.
Some joined documents are not saved/deleted, why?
To avoid infinite recursion with circular references (that appear as soon as you have
a reciprocal relationship), saveAll
will not recurse in a field containing document(s)
of a previously saved model.
The same goes for delete.
How can I enforce uniqueness in a field?
If you must be sure that a field is unique, you must use it as the primary key.
For example, suppose you want the name to be unique.
var Model = thinky.createModel("user", {
name: type.string()
}, {
pk: "name"
});
Note: If you use a field as a primary key, you will not be able to update the field. You will have to delete and re-insert the document.
RethinkDB does not provide unique secondary indexes (like any distributed databases), mostly because as soon as you shard your table, uniqueness cannot be enforced without a huge cost in performance – See this discussion for more details.
What is thinky’s license
MIT license.
How can I contact you?
- Ping me on twitter at @neumino.
- I hang out as
neumino
on freenode/rethinkdb. - If you run into a problem, please open an issue on GitHub.