Comparing version 0.2.4 to 0.2.5
@@ -1209,2 +1209,3 @@ /** | ||
AbstractClass.belongsTo = function (anotherClass, params) { | ||
var modelName = this.modelName; | ||
var methodName = params.as; | ||
@@ -1221,3 +1222,3 @@ var fk = params.foreignKey; | ||
this.schema.defineForeignKey(this.modelName, fk); | ||
this.schema.defineForeignKey(modelName, fk); | ||
this.prototype['__finders__'] = this.prototype['__finders__'] || {}; | ||
@@ -1231,6 +1232,10 @@ | ||
anotherClass.findById(id, function (err, inst) { | ||
if(!inst) { | ||
return cb(new Error(modelName + ' belongsTo ' + anotherClass.modelName + ' via foreign key ' + fk + ' error')); | ||
} | ||
var sid = typeof inst.id === 'object' ? inst.id.toString() : inst.id; | ||
var fid = typeof this[fk] === 'object' ? this[fk].toString() : this[fk]; | ||
if (err) | ||
if (err) { | ||
return cb(err); | ||
} | ||
if (!inst) | ||
@@ -1237,0 +1242,0 @@ return cb(null, null); |
@@ -283,3 +283,3 @@ /** | ||
RethinkDB.prototype.defineForeignKey = function (name, key, anotherName, cb) { | ||
RethinkDB.prototype.defineForeignKey = function (name, key, cb) { | ||
this._foreignKeys[name].push(key); | ||
@@ -286,0 +286,0 @@ cb(null, String); |
{ | ||
"name": "caminte", | ||
"description": "ORM for every database: redis, mysql, neo4j, mongodb, rethinkdb, postgres, sqlite, tingodb", | ||
"version": "0.2.4", | ||
"version": "0.2.5", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Aleksej Gordejev", |
@@ -39,2 +39,24 @@ [![Build Status](https://travis-ci.org/biggora/caminte.png?branch=master)](https://travis-ci.org/biggora/caminte) | ||
## Overview | ||
* [Command line interface](https://github.com/biggora/caminte#cli) | ||
* [Usage](https://github.com/biggora/caminte#usage) | ||
* [Connecting to DB](https://github.com/biggora/caminte/wiki/Connecting-to-DB#connecting) | ||
* [Defining a Model](https://github.com/biggora/caminte/wiki/Defining-a-Model#define-model) | ||
* [Define Indices](https://github.com/biggora/caminte/wiki/Defining-a-Model#define-indices) | ||
* [Define Primary Keys](https://github.com/biggora/caminte/wiki/Defining-a-Model#define-primary-keys) | ||
* [Schema data types](https://github.com/biggora/caminte/wiki/Schema-data-types#types) | ||
* [Accessing a Model](https://github.com/biggora/caminte/wiki/Defining-a-Model#accessing-a-model) | ||
* [Setup Relationships](https://github.com/biggora/caminte/wiki/Setup-Relationships-&-Validations#setup-relationships) | ||
* [Setup Validations](https://github.com/biggora/caminte/wiki/Setup-Relationships-&-Validations#setup-validations) | ||
* [Common API methods](https://github.com/biggora/caminte/wiki/Common-API-methods#api) | ||
* [Define any Custom Method](https://github.com/biggora/caminte/wiki/Common-API-methods#custom) | ||
* [Query Interface](https://github.com/biggora/caminte/wiki/Query-Interface#queries) | ||
* [Middleware (Hooks)](https://github.com/biggora/caminte/wiki/Middleware#middleware) | ||
* [Object lifecycle](https://github.com/biggora/caminte/wiki/Object-lifecycle#lifecycle) | ||
* [Your own database adapter](https://github.com/biggora/caminte/wiki/Your-own-database-adapter#adapter) | ||
* [Running tests](https://github.com/biggora/caminte/wiki/Running-tests) | ||
## Online model creator | ||
@@ -73,20 +95,3 @@ | ||
## Overview | ||
* [Connecting to DB](https://github.com/biggora/caminte/wiki/Connecting-to-DB#connecting) | ||
* [Defining a Model](https://github.com/biggora/caminte/wiki/Defining-a-Model#define-model) | ||
* [Define Indices](https://github.com/biggora/caminte/wiki/Defining-a-Model#define-indices) | ||
* [Define Primary Keys](https://github.com/biggora/caminte/wiki/Defining-a-Model#define-primary-keys) | ||
* [Schema data types](https://github.com/biggora/caminte/wiki/Schema-data-types#types) | ||
* [Accessing a Model](https://github.com/biggora/caminte/wiki/Defining-a-Model#accessing-a-model) | ||
* [Setup Relationships](https://github.com/biggora/caminte/wiki/Setup-Relationships-&-Validations#setup-relationships) | ||
* [Setup Validations](https://github.com/biggora/caminte/wiki/Setup-Relationships-&-Validations#setup-validations) | ||
* [Common API methods](https://github.com/biggora/caminte/wiki/Common-API-methods#api) | ||
* [Define any Custom Method](https://github.com/biggora/caminte/wiki/Common-API-methods#custom) | ||
* [Query Interface](https://github.com/biggora/caminte/wiki/Query-Interface#queries) | ||
* [Middleware (Hooks)](https://github.com/biggora/caminte/wiki/Middleware#middleware) | ||
* [Object lifecycle](https://github.com/biggora/caminte/wiki/Object-lifecycle#lifecycle) | ||
* [Your own database adapter](https://github.com/biggora/caminte/wiki/Your-own-database-adapter#adapter) | ||
* [Running tests](https://github.com/biggora/caminte/wiki/unning-tests#running_tests) | ||
## Usage | ||
@@ -198,27 +203,2 @@ | ||
## Tests | ||
``` | ||
# run all tests | ||
$ make test | ||
# run sqlite tests | ||
$ make test-sqlite | ||
# run mysql tests | ||
$ make test-mysql | ||
# run postgres tests | ||
$ make test-postgres | ||
# run redis tests | ||
$ make test-redis | ||
# run mongodb tests | ||
$ make test-mongo | ||
# run rethinkdb tests | ||
$ make test-rethinkdb | ||
``` | ||
## Contributing | ||
@@ -225,0 +205,0 @@ |
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
13780
698416
251