-
Notifications
You must be signed in to change notification settings - Fork 34
Open
Description
When I use custom field name, the fields are not inserted. Such like:
var User = schema.define('User', {
lastLogin: { name: 'last_login', type: Date }
});In lib/postgres.js:
PG.prototype.toFields = function (model, data, forCreate) {
var fields = [];
var props = this._models[model].properties;
if(forCreate){
var columns = [];
Object.keys(data).forEach(function (key) {
if (props[key]) { // I think problem is here!!
if (key === 'id') return;
columns.push('"' + key + '"');
fields.push(this.toDatabase(props[key], data[key]));
}
}.bind(this));
return '(' + columns.join(',') + ') VALUES ('+fields.join(',')+')';
}else{
Object.keys(data).forEach(function (key) {
if (props[key]) {
fields.push('"' + key + '" = ' + this.toDatabase(props[key], data[key]));
}
}.bind(this));
return fields.join(',');
}
};In above function, props is:
{
lastLogin: { name: 'last_login', type: [Function: Date] }
}and Object.keys(data) is [ 'last_login' ]. So. props[key] is false and ignore the fields I use custom name.
I'm not sure this is handle in whether jugglingdb or postgres-adapter.
Metadata
Metadata
Assignees
Labels
No labels