Comparing version 0.2.4 to 0.2.5
@@ -9,4 +9,4 @@ { | ||
"ejs" : "0.8.3", | ||
"thinky" : "0.2.3" | ||
"thinky" : "0.2.4" | ||
} | ||
} |
@@ -43,3 +43,3 @@ var thinky = require( 'thinky' ); | ||
todo.delete( function ( err, todo ){ | ||
todo.delete(null, function ( err, todo ){ | ||
if( err ) return next( err ); | ||
@@ -46,0 +46,0 @@ |
@@ -128,3 +128,3 @@ var eventEmitter = require('events').EventEmitter; | ||
if ((originalDoc != null) && (joinClause != null) && (originalDoc !== doc)) { | ||
originalDoc._save(callback, false); | ||
originalDoc.save( {saveJoin: false}, callback); | ||
} | ||
@@ -147,2 +147,4 @@ else { | ||
joinClause, joinType, saveJoin) { | ||
//TODO remove originalCopyDoc | ||
//TODO Clean all the dead code... | ||
var arg = arguments; | ||
@@ -180,3 +182,3 @@ var docSettings = doc.getDocSettings(); | ||
//TODO We don't need _save. Clean and merge _save and save | ||
Document.prototype.save = function(callback, options) { | ||
Document.prototype.save = function(options, callback) { | ||
if ((options == null) || (options.saveJoin == null)) { | ||
@@ -187,2 +189,3 @@ options = { | ||
} | ||
/* | ||
this._save(callback, options.saveJoin); | ||
@@ -192,2 +195,3 @@ } | ||
Document.prototype._save = function(callback, saveJoin) { | ||
*/ | ||
//TODO Implement replace to delete fields | ||
@@ -197,3 +201,3 @@ | ||
var model = this.getModel(); | ||
var docSettings = self.getDocSettings(); | ||
@@ -208,3 +212,3 @@ var query, cb; | ||
if (saveJoin === true) { | ||
if (options.saveJoin === true) { | ||
for(var key in self) { | ||
@@ -227,3 +231,3 @@ if (self.hasOwnProperty(key) === true) { | ||
} | ||
self[key][i]._save(cb, true); | ||
self[key][i].save({saveJoin: true}, cb); | ||
} | ||
@@ -241,3 +245,3 @@ } | ||
} | ||
self[key]._save(cb, true); | ||
self[key].save({saveJoin: true}, cb); | ||
} | ||
@@ -291,3 +295,3 @@ } | ||
if ((options == null) || (options.saveJoin == null)) { | ||
if ((options == null) || (options.deleteJoin == null)) { | ||
options = { | ||
@@ -314,3 +318,3 @@ deleteJoin: false | ||
if (typeof model.joins[key].joinClause === 'object') { | ||
cb = Document.createCallbackDelete(self[key][i], callback, count, self, copyDoc, | ||
cb = Document.createCallbackDelete(self[key][i], callback, count, self, null, | ||
model.joins[key].joinClause, 'hasMany', false) | ||
@@ -322,3 +326,3 @@ } | ||
} | ||
self[key][i].delete(cb, true); | ||
self[key][i].delete({deleteJoin: true}, cb); | ||
} | ||
@@ -329,3 +333,3 @@ } | ||
if (typeof model.joins[key].joinClause === 'object') { | ||
cb = Document.createCallbackDelete(self[key], callback, count, self, copyDoc, | ||
cb = Document.createCallbackDelete(self[key], callback, count, self, null, | ||
model.joins[key].joinClause, 'hasOne', false) | ||
@@ -337,3 +341,3 @@ } | ||
} | ||
self[key].delete(cb, true); | ||
self[key].delete({deleteJoin: true}, cb); | ||
} | ||
@@ -340,0 +344,0 @@ } |
{ | ||
"name": "thinky", | ||
"version": "0.2.4", | ||
"version": "0.2.5", | ||
"description": "RethinkDB ORM for Node.js", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -101,3 +101,3 @@ var thinky = require('../lib/index.js'); | ||
catou.save( function(error, result) { | ||
catou.save(null, function(error, result) { | ||
should.exist(result.id); | ||
@@ -110,3 +110,3 @@ done(); | ||
catou = new Cat({name: 'Catou'}); | ||
catou.save( function(error, result) { | ||
catou.save(null, function(error, result) { | ||
should.equal(catou, result); | ||
@@ -120,3 +120,3 @@ catouCopy = result; | ||
minou = new Cat({name: 'Minou'}); | ||
minou.save( function(error, result) { | ||
minou.save(null, function(error, result) { | ||
should.equal(minou, result); | ||
@@ -131,3 +131,3 @@ minouCopy = result; | ||
catou.save( function(error, result) { | ||
catou.save(null, function(error, result) { | ||
should.equal(result.name, value); | ||
@@ -141,3 +141,3 @@ done(); | ||
catou.save( function(error, result) { | ||
catou.save(null, function(error, result) { | ||
should.equal(catou, result); | ||
@@ -154,3 +154,3 @@ | ||
catou.save( function(error, result) { | ||
catou.save(null, function(error, result) { | ||
should.exist(result.id); | ||
@@ -157,0 +157,0 @@ catou.delete( null, function(error, result) { |
@@ -387,3 +387,3 @@ var thinky = require('../lib/index.js'); | ||
catou = new Cat({name: 'Catou'}); | ||
catou.save( function(error, result) { | ||
catou.save(null, function(error, result) { | ||
g.catouCopy = result; | ||
@@ -393,3 +393,3 @@ | ||
var minou = new Cat({name: 'Minou'}); | ||
minou.save( function(error, result) { | ||
minou.save(null, function(error, result) { | ||
minouCopy = result; | ||
@@ -408,3 +408,3 @@ done(); | ||
var catou = new Cat({name: 'Catou'}); | ||
catou.save( function(error, result) { | ||
catou.save(null, function(error, result) { | ||
scope.catou = result; | ||
@@ -414,3 +414,3 @@ should.exist(result.id); | ||
var minou = new Cat({name: 'Minou'}); | ||
minou.save( function(error, result) { | ||
minou.save(null, function(error, result) { | ||
scope.minou = result; | ||
@@ -460,3 +460,3 @@ done(); | ||
var catou = new Cat({name: 'Catou'}); | ||
catou.save( function(error, result) { | ||
catou.save(null, function(error, result) { | ||
scope.catou = result; | ||
@@ -466,3 +466,3 @@ should.exist(result.id); | ||
var minou = new Cat({name: 'Minou'}); | ||
minou.save( function(error, result) { | ||
minou.save(null, function(error, result) { | ||
scope.minou = result; | ||
@@ -506,3 +506,3 @@ done(); | ||
var catou = new Cat({name: 'Catou'}); | ||
catou.save( function(error, result) { | ||
catou.save(null, function(error, result) { | ||
scope.catou = result; | ||
@@ -512,3 +512,3 @@ should.exist(result.id); | ||
var minou = new Cat({name: 'Minou'}); | ||
minou.save( function(error, result) { | ||
minou.save(null, function(error, result) { | ||
scope.minou = result; | ||
@@ -670,3 +670,3 @@ done(); | ||
catou['owner'] = owner; | ||
catou.save( function(error, result) { | ||
catou.save({saveJoin: true}, function(error, result) { | ||
should.exist(catou.id); | ||
@@ -676,3 +676,3 @@ should.exist(catou.idHuman); | ||
done(); | ||
}, {saveJoin: true}); | ||
}); | ||
}); | ||
@@ -692,3 +692,3 @@ it('should be able to save the joined doc -- nested joins', function(done) { | ||
catou.save( function(error, result) { | ||
catou.save( {saveJoin: true}, function(error, result) { | ||
should.exist(catou.id); | ||
@@ -699,3 +699,3 @@ should.exist(catou.idHuman); | ||
done(); | ||
}, {saveJoin: true}); | ||
}); | ||
}); | ||
@@ -734,3 +734,3 @@ it('get should be able to get joined documents', function(done) { | ||
catou.save( function(error, result) { | ||
catou.save( {saveJoin: true}, function(error, result) { | ||
should.exist(catou.id); | ||
@@ -746,3 +746,3 @@ should.exist(catou.idHuman); | ||
}) | ||
}, {saveJoin: true}); | ||
}); | ||
}); | ||
@@ -764,3 +764,3 @@ | ||
catou.save( function(error, result) { | ||
catou.save({saveJoin: true}, function(error, result) { | ||
should.exist(catou.id); | ||
@@ -776,3 +776,3 @@ should.exist(catou.idHuman); | ||
catou1.save( function(error, result) { | ||
catou1.save({saveJoin: true}, function(error, result) { | ||
Cat.getAll([catou.id, catou1.id], {index: 'id', getJoin: true}, function(error, result) { | ||
@@ -796,5 +796,5 @@ result.should.have.length(2); | ||
}) | ||
}, {saveJoin: true}) | ||
}) | ||
}, {saveJoin: true}); | ||
}); | ||
}); | ||
@@ -814,3 +814,3 @@ it('filter should work -- nested joins', function(done) { | ||
catou.save( function(error, result) { | ||
catou.save({saveJoin: true}, function(error, result) { | ||
should.exist(catou.id); | ||
@@ -826,3 +826,3 @@ should.exist(catou.idHuman); | ||
catou1.save( function(error, result) { | ||
catou1.save({saveJoin: true}, function(error, result) { | ||
Cat.filter(function(doc) { return r.expr([catou.id, catou1.id]).contains(doc("id")) }, | ||
@@ -848,5 +848,5 @@ {getJoin: true}, | ||
) | ||
}, {saveJoin: true}) | ||
}) | ||
}, {saveJoin: true}); | ||
}); | ||
}); | ||
@@ -875,3 +875,3 @@ }) | ||
catou.tasks = [task1, task2, task3]; | ||
catou.save( function(error, result) { | ||
catou.save({saveJoin: true}, function(error, result) { | ||
catou.taskIds.should.have.length(3); | ||
@@ -886,3 +886,3 @@ should.exist(catou.taskIds[0]); | ||
done(); | ||
}, {saveJoin: true}); | ||
}); | ||
}); | ||
@@ -889,0 +889,0 @@ it('get should be able to get joined documents', function(done) { |
@@ -113,3 +113,3 @@ var thinky = require('../lib/index.js'); | ||
catou = new Cat({name: 'Catou'}); | ||
catou.save( function(error, result) { | ||
catou.save(null, function(error, result) { | ||
should.equal(error.name, 'RqlRuntimeError'); | ||
@@ -116,0 +116,0 @@ done(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
1558602
34684
48