Fix id:null issue #98
This commit is contained in:
parent
f26096aab4
commit
e10c42ed1b
|
@ -1,3 +1,4 @@
|
|||
|
||||
var safeRequire = require('../utils').safeRequire;
|
||||
|
||||
/**
|
||||
|
@ -52,6 +53,7 @@ exports.initialize = function initializeSchema(schema, callback) {
|
|||
};
|
||||
|
||||
function MongoDB(s, schema, callback) {
|
||||
var i, n;
|
||||
this._models = {};
|
||||
this.collections = {};
|
||||
|
||||
|
@ -102,6 +104,9 @@ MongoDB.prototype.collection = function (name) {
|
|||
};
|
||||
|
||||
MongoDB.prototype.create = function (model, data, callback) {
|
||||
if (data.id === null) {
|
||||
delete data.id;
|
||||
}
|
||||
this.collection(model).insert(data, {}, function (err, m) {
|
||||
callback(err, err ? null : m[0]._id.toString());
|
||||
});
|
||||
|
@ -231,3 +236,4 @@ MongoDB.prototype.updateAttributes = function updateAttrs(model, id, data, cb) {
|
|||
MongoDB.prototype.disconnect = function () {
|
||||
this.client.close();
|
||||
};
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ var safeRequire = require('../utils').safeRequire;
|
|||
var mongoose = safeRequire('mongoose');
|
||||
|
||||
exports.initialize = function initializeSchema(schema, callback) {
|
||||
console.error('WARN: mongoose adapter is not supported, please use "mongodb" adapter instead');
|
||||
if (!mongoose) return;
|
||||
|
||||
if (!schema.settings.url) {
|
||||
|
|
Loading…
Reference in New Issue