• Start

Methods

Update

The .NET SDK for SurrealDB enables simple and advanced querying of a remote or embedded database.

Updates all records in a table, or a specific record, in the database.

Method Syntax
await db.Update<T>(thing, data)
Note

This function replaces the current document / record data with the specified data.

Arguments

Description

thing

The table name or the specific RecordId to update.

data

The document / record data to update.

cancellationToken

The cancellationToken enables graceful cancellation of asynchronous operations.

var post = new Post
{
    Id = ("post", "another"),
    Title = "A new article",
    Content = "This is a new article created using the .NET SDK"
};

// Updates a single record
await db.Update(post);

var data = new Person
{
    Name = "Tobie",
    Settings = new Settings
    {
        Active = true,
        Marketing = true,
    },
};

// Updates all records inside the "person" table
await db.Update("person", data);

Was this page helpful?