Class Entry<TCollectionRecordData>

Type Parameters

  • TCollectionRecordData

    Dataset record's data

Hierarchy

Methods

  • Load record from API

    Example

    import { Corva } from '@corva/node-sdk';

    export const handler = new Corva().stream(async (event, context) => {
    const entry = context.api.provider('some-provider').dataset('some-collection').entry('some-id');

    context.logger.info(entry.instance); // undefined

    await entry.get();

    context.logger.info(entry.instance); // JSON
    });

    Returns Promise<CollectionRecord<TCollectionRecordData, unknown>>

  • Remove current record

    Example

    import { Corva } from '@corva/node-sdk';

    export const handler = new Corva().stream(async (event, context) => {
    const entry = await context.api.provider('some-provider').dataset('some-collection').findOne({});

    context.logger.info(entry.instance); // JSON

    await entry.remove();

    context.logger.info(entry.instance); // JSON, still there

    await entry.update({ any: 'data' }); // will throw an error
    });

    Returns Promise<RemoveFromCollectionResponseBody>

  • Fully replace current record

    Parameters

    • data: TCollectionRecordData

    Returns Promise<CollectionRecord<TCollectionRecordData, unknown>>

  • Update current record

    Example

    import { Corva } from '@corva/node-sdk';

    export const handler = new Corva().stream(async (event, context) => {
    const entry = await context.api.provider('some-provider').dataset('some-collection').findOne({});

    context.logger.info(entry.instance); // JSON

    await entry.update({ some: 'data' });

    context.logger.info(entry.instance); // JSON, { data: { some: 'data' } }
    });

    Parameters

    • data: Partial<TCollectionRecordData>
    • Optional schemaVersion: number

    Returns Promise<CollectionRecord<TCollectionRecordData, unknown>>