Skip to main content

Data Containers

dcupl allows you to add data to your models in different formats and multiple ways. You can either fetch it manually in the context of your application logic and add it via dcupl.data.set(...) or you use our dcupl Loader to do the job. Either way, when adding data to a dcupl project, we are doing this via DataContainers.

export type DataContainer = {
model: string;
data: any[];
type?: 'update' | 'upsert' | 'set' | 'delete';
keyProperty?: string;
autoGenerateKey?: boolean;
};

model

A DataContainer consists of the raw data from your API and some instructions on how to interpret it. The first and obvious one is that you have to define the model, to which this data should be applied to.

type

You can also specify the type of action this dataset should perform when being processed.

  • update - will update existing data entries.
  • upsert - will update existing data entries or insert new data entries, if the specified key is not yet present.
  • set - will remove any existing data and use this newly added data as the new baseline.
  • delete - will simply remove the data entries which are listed in the data array.

keyProperty

The keyProperty attribute in a DataContainer specifies an alternative key property. Per default dcupl expects the data to have a property called key to be present to identify the data entry. The value of the key should be unique to prevent side effects.

autoGenerateKey

If the provided dataset does not have a property which identifies individual rows/entries at all, dcupl is able to generate a key on the fly.