rethinkdb-traits
Advanced tools
Comparing version 0.0.2 to 0.0.3
{ | ||
"name": "rethinkdb-traits", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "A RethinkDB query composer.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# rethinkdb-traits | ||
A library to compose rethinkdb queries with NodeJS | ||
This is not an ORM. It's a library to organise related queries around tables. It does not assume anything about relations, but rather let's you express relations yourself, through functions. | ||
A library to compose rethinkdb queries with NodeJS. | ||
This is not an ORM. It's a library to organize your queries. It does not assume anything about relations. | ||
It *does* create table on definition, and indexes as well. It makes it easier to perform queries, in a modelish way, without having a reference to the connection. | ||
## To install | ||
@@ -26,13 +29,18 @@ ```shell | ||
const groupTraits = { | ||
byName: function (rql,name) { | ||
return rql.filter({ name }); | ||
}, | ||
withPeople: function (rql) { | ||
const $r = this.$r; | ||
return rql.merge(function(group) { | ||
return group.merge({ | ||
people: this.$r.table('people').getAll(group('id'), { index: 'groupId' }); | ||
people: $r.table('people').getAll(group('id'), { index: 'groupId' }); | ||
}); | ||
}) | ||
}, | ||
// you can chain and reuse 'before' and 'after' functions | ||
after: { | ||
withPeople: [ | ||
'byName,withPeople': [ | ||
function (rql) { | ||
@@ -84,3 +92,3 @@ | ||
logJson(groups); | ||
console.log(groups); | ||
return Promise.all([Person.delete(),Group.delete()]); | ||
@@ -87,0 +95,0 @@ }).then( () => { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24136
136