@dxos/echo
    Preparing search index...

    Interface Transaction

    Structural changes to a database, staged and then committed atomically.

    Staged changes are not visible to queries until Transaction.commit. Use it for changes that an ordinary write cannot express: changing an object's type in place, removing objects without a tombstone, or dropping document history. For schema changes that a write can express, prefer define. Run it with db.runMigrations through defineTransaction, or directly:

    const migration = await space.db.beginMigration();
    yield* migration.migrate(contact.id, (json) => Obj.make(ContactV2, { id: json.id, name: String(json.name) }));
    migration.add(Obj.make(Note, { title: 'Imported' }));
    migration.delete(legacy.id);
    yield* migration.commit();
    interface Transaction {
        add(object: Obj.Unknown): void;
        commit(): Effect<void, MigrationError>;
        compact(ids?: readonly string[]): CompactResult;
        delete(id: string): void;
        get(id: string): Effect<Option<ObjectJSON>, MigrationError>;
        migrate<E = never, R = never>(
            id: string,
            transform: (
                current: ObjectJSON,
            ) => Obj.Unknown | Effect<Obj.Unknown, E, R>,
        ): Effect<boolean, MigrationError | E, R>;
        replace(object: Obj.Unknown): void;
    }
    Index

    Methods

    • Stages object in place of the stored object with the same id, replacing its type, data and meta. The object's document keeps its history, so concurrent edits from peers still merge.

      Parameters

      Returns void

      When no object with that id is stored.