brikteknologier / seraph-model

thin model layer for seraph/neo4j (node.js)
MIT License
111 stars 28 forks source link

nested object saving is not working with neo4j 3.0.3 #111

Closed ghost closed 8 years ago

ghost commented 8 years ago

nested object saving is not working with neo4j 3.0.3

user model

var db = require('../config/db').db; var model = require('seraph-model'); var User = model(db, 'User'); var profile = require('./profile').Profile; var role = require('./role').Role;

User.compose(profile, 'profile', 'HAS_PROFILE'); User.compose(role, 'role', 'HAS_ROLE');

User.setUniqueKey('userId');

User.schema = { userId : {type: String, required: true}, password : {type: String, required: true}, createdOn : {type: Date, default : new Date().getTime()} };

exports.User = User;


saving user data

userModel.save(property, function(err, saved) { console.log(saved); db.relationships(saved, function(err, rels) { console.log(rels) });

    // Read directly with seraph
    db.read(saved, function(err, userInfo) {
        console.log(userInfo)

    })

    // Read with model, and you get compositions implicitly.
    userModel.read(saved, function(err, userInfo) {
        console.log(userInfo)

    });

});

.save is working for 2.3.2 but not working for 3.0.3 please suggest

jonpacker commented 8 years ago

This should work now, please try updating to 0.8.3.