Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

saveAll with sub relational document removal throwing validation Error. #612

Open
valayDave opened this issue Apr 3, 2017 · 1 comment

Comments

@valayDave
Copy link

valayDave commented Apr 3, 2017

The documentation for saving relational documents and deleting them shows the following:


var Advertizer = thinky.createModel("Advertizer", {
    name: type.string(),
});
var Contract = thinky.createModel("Contract", {
    advId: type.string(),
    dateTo: type.date(),
    dateFrom: type.date()
    regionId : type.string()
});

var Region = thinky.createModel("Region", {
    name: type.string(),
});

Advertizer.hasMany(Contract, "contracts", "id", "advId");
Contract.belongsTo(Advertizer, "advertizer", "advId", "id");

Region.hasMany(Contract, "contracts", "id", "regionId");
Contract.belongsTo(Region, "region", "regionId", "id");

Advertizer.get("3851d8b4-5358-43f2-ba23-f4d481358901").getJoin({contracts:true}).run()
    .then(function(adv) {

    adv.contracts.splice(1, 1);
    adv.saveAll({contracts: true}).then(function(newAdv) {
        
    }).error(function(err){
    
    });
});

When I do the adv.saveAll() I get a validation Error saying advId must be defined. I am doing it the same way it is shown on thinky documentation.

What can be the issue?

@neumino
Copy link
Owner

neumino commented Apr 5, 2017

Maybe because id is not declared in your schema?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants