brikteknologier / seraph-model

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

Partial update #103

Closed Masadow closed 8 years ago

Masadow commented 8 years ago

This should be a must. Save always erase everything on update. If a field is not specified, it should not remove it.

jonpacker commented 8 years ago

I agree. How would suggest integrating into the api?

In the mean time, you can use a cypher query to update a single or set of properties on a node non-destructively.

jonpacker commented 8 years ago

Sorry, referenced the wrong issue there.

jonpacker commented 8 years ago

Although it sounds like he was talking about something different, I think the idea of a model.merge function could work here. Something that works essentially the same way as model.save, but does an additive update only. What do you think?

Masadow commented 8 years ago

Since this API is very close to mongoose which I came from (like many others ?). It would looks familiar to me to have a model.update method.

model.merge could also work, but it's less conventional I guess.

Best would be to keep using model.save, but it would be too much overhead if you ever want to keep deleting keys to know whether or not you want to update or remove keys.

jonpacker commented 8 years ago

Yeah, I'd be alright with using update as well. My primary reasoning for not using save is that seraph-model should behave consistently with seraph, and seraph's behaviour is defined by the neo4j api. Which is how we got here in the first place...