-
Notifications
You must be signed in to change notification settings - Fork 369
Closed
Labels
Description
Suppose I have a model like this:
var GraphNode = db.define("GraphNode", {
node_id: Number,
working_dir: String,
config: Object
});Upon creation unless the created object's field contains a JSON string it will be null. It will always be a string from the database, but in a situation where I am creating the object it does not always make sense. I think that both cases below should work.
// Currently not possible, config will be null
new GraphNode({
node_id: 0
working_dir: "/some/directory",
config: {
a_field: "some value"
}
});
// As opposed to
new GraphNode({
node_id: 0
working_dir: "/some/directory",
config: '{"a_field": "some value"}'
});
// ...I have a workaround for the Postgres driver at least, by editing lib/Drivers/DML/postgres.js and adding the following code right below case "object" (https://github.com/dresende/node-orm2/blob/master/lib/Drivers/DML/postgres.js#L252)
if (value === Object(value)) {
return value;
}It may be as simple as adding that to all of the drivers.
Reactions are currently unavailable