Delete
Delete allows you to remove Items by one of their key paths. You can use any of the Item’s key paths and the Item will be deleted from all of them. Delete doesn’t return anything, whether or not anything was actually deleted (e.g. if there wasn’t any Item at the given key path). Delete also supports batches of up to 50 key paths at a time.
For this example we’ll use the schema defined in Example: Movies Schema, which defines Movie
as an Item Type with the key path /movies-:id
.
17 collapsed lines
package main
import ( "context" "fmt" "os" "slices" "strconv" "time"
"github.com/google/uuid"
"github.com/StatelyCloud/go-sdk/stately" // This is the code you generated from schema "github.com/StatelyCloud/stately/go-sdk-sample/schema")
func sampleDelete( ctx context.Context, client stately.Client, movieID uuid.UUID,) error { return client.Delete(ctx, "/movie-"+stately.ToKeyID(movieID[:]))}
5 collapsed lines
require 'bundler/setup'require_relative 'schema/stately'require 'byebug'
def sample_delete(client, movie_id)
key_path = StatelyDB::KeyPath.with('movie', movie_id) client.delete(key_path)
end
9 collapsed lines
from __future__ import annotations
from typing import TYPE_CHECKING
from statelydb import ListToken, SyncChangedItem, SyncDeletedItem, SyncReset, key_path
from .schema import Actor, Change, Character, Client, Movie
async def sample_delete(client: Client, movie_id: UUID) -> None: kp = key_path("movie-{id}", id=movie_id) await client.delete(kp)
3 collapsed lines
import { createClient, DatabaseClient, Movie } from "./schema/index.js";import { keyPath, ListToken } from "@stately-cloud/client";
async function sampleDelete(client: DatabaseClient) { // Put a movie let movie = await client.put( client.create("Movie", { genre: "action", year: 1997n, title: "Starship Troopers", rating: "R", duration: 7_740n, }), );
// Delete the movie await client.del(keyPath`/movie-${movie.id}`);}
# There are no key path helpers for shell, so you need to# manually base64-encode the UUID's bytesstately item delete \ --store-id <store-id-goes-here> \ --item-key '/movie-2hC3sMFFSlelJlFf9hRD9g'
Tombstones
Deleted Items leave behind a “tombstone” record which lets you know that they have been deleted. You can’t interact with the tombstone through any of our APIs, but it’s important that they exist to allow SyncList to tell you about Items that have been deleted since your last sync. Tombstones take up very little space and are automatically cleaned up after some time (on the order of weeks).