.Create<T>()
Creates a record in the database.
Method Syntaxawait db.Create<T>(resource, data)
Arguments | Description | ||
---|---|---|---|
thing required | The table name or a | ||
data optional | The document / record data to insert. | ||
cancellationToken optional | The cancellationToken enables graceful cancellation of asynchronous operations. |
// Create a record with a random ID var person = await db.Create<Person>("person"); // Create a record with a random ID & specific fields var person = await db.Create("person", new Person { Name = "Tobie" }); // Create a record with a specific ID var personToCreate = new Person { Id = ("person", "tobie"), Name = "Tobie", Settings = new Settings { Active = true, Marketing = true, }, }; var result = await db.Create(personToCreate);