13 Create, insert, update, delete
In the examples, db is ctx.Database, the NodeStore.
Create<T>() makes a node object in memory and gives it a new id. Nothing is stored until you insert
it:
var venue = db.Create<IVenue>(); // in memory only
venue.Name = "Sentrum Scene";
venue.Location = new GeoCoordinate(59.9200, 10.7480);
venue.Capacity = 1750;
venue.Kind = VenueKind.Indoor;
db.Insert(venue); // now it is stored
db.UpdateAddress(venue.Id, "sentrum-scene"); // Slug is the node's address (§4)CreateAndInsert does both in one transaction. The callback also gets that transaction, so you can
relate the new node in the same commit:
var ev = db.CreateAndInsert<IEvent>((e, t) => {
e.Title = "Winter Session";
e.StartsUtc = new DateTime(2026, 11, 14, 19, 0, 0, DateTimeKind.Utc);
e.Duration = TimeSpan.FromHours(3);
e.Price = 450m;
e.Status = EventStatus.Published;
e.Tags = ["live", "electronic"];
t.AddRelation<IEvent>(e, x => x.Venue, venue);
});Insert throws if a node with the same id exists; InsertIfNotExists skips it instead. Insert also
inserts related node objects that are not stored yet, and relates them. Pass ignoreRelated: true
when you have inserted them yourself.
- Read — Get throws when the id is missing or the node is not a T; TryGet returns false. A node whose type inherits from T counts as a T. A read by id applies the store's culture but not its read access. To find out what a user…
- Update, upsert, delete — Update writes every property of the node object back. It does not change relations: use the methods of chapter 14 for those.