-
Notifications
You must be signed in to change notification settings - Fork 4
Using a Model
Jean-Baptiste Musso edited this page Oct 28, 2013
·
1 revision
Saves current model in the graph database. Will create a vertex if new, or update one if already existing (currently only checks for an existing or missing _id
property).
Usually called by save()
update()
ignores properties not defined the schema definition and will not change their values. There currently is no option to modify this behavior.
Usually called by save()
Executes a Gremlin query, and return data as model instances or as raw data. Note that asModel
is optional and defaults to true.
Find a model by a given property name. Will only return the first of all found vertices.
User.findOne({name: "John"}, function(error, model) {
// Check for error, and do something with model
});
Gremlin:
g.V("name", "John")[0]
Find a model by vertex id.
User.findById(4, function(error, model) {
// ..
});
Gremlin:
g.v(4)
Delete a model by vertex id.
User.delete(4, function(error, result) {
// ..
});
Gremlin:
g.removeVertex(g.v(id))