Skip to main content

Store source

The store is the general-purpose source for data you own and manage: entered by hand, written by your code, uploaded from files, and freely edited afterwards. It is the default choice when you create a source.

For data you enter and manage yourself. Add records one at a time, or upload a file to bring in a batch at once, and keep extending it.

What makes it different from the other types: you are in control of every entry, from the app and from code, at any time.

Four ways to put data in​

Use any of them, mix them, and repeat them. They all write to the same source.

WayGood for
The app: create document in the Documents tabSingle entries, corrections, small reference lists
REST API and SDK: Doc.create, Doc.update, Doc.batchInsertYour applications writing records programmatically
File upload: CSV, JSON, JSONLBulk loads, initial data, exports from other tools
Repeated uploadsExtending the source over time with more files

Edit and delete entries​

Store entries are fully editable, in the app and through the API:

  • In the app, open a document and edit it, or delete it.
  • Through the API, Doc.update replaces a document, or merges fields with update: true. Doc.delete removes it.
  • Edits are applied to the raw data and re-typed into the main data, so charts reflect the change immediately.
const orders = sdk.asAdmin().Insights().Source('Orders')

await orders.Doc.update(docId, { status: 'shipped' }, { update: true })
await orders.Doc.delete(docId)

Most other source types are read-only in Scenid because the data belongs to an upstream system.

Upload files, and upload more​

Open the File upload tab and choose a file. The wizard walks through File, Analysis, Fields and Mapping:

  1. Choose the format: CSV, JSON (an array of objects) or JSONL (one JSON object per line).
  2. Scenid analyses the file and proposes the fields and their types.
  3. Fields that already exist in the source are matched automatically. Fields that are new are added to the source.
  4. Start the import.

You can upload another file at any time to add more entries. There is no limit on the number of uploads (one at a time: while an import is running, the next upload waits for it to finish). The File imports list on the Information tab records every upload with how many documents were created, updated, skipped or failed.

Field mapping

Fields in a new file that do not match an existing field become new fields on the source. Renaming during upload is not available yet.

A database backend for your app​

Every document of a store can be handled directly through the API and the SDK: create, read, update, delete, and bulk insert. That makes a store a ready-made backend for your own application: no database to host, and the same data is instantly available for charts, dashboards and exports. Define the fields (with their types) first: values for fields that are not defined on the source are dropped.

You needYou use
A record by its keyDoc.get(id)
InsertDoc.create(body), Doc.batchInsert(docs)
Change a recordDoc.update(id, body) (replace) or Doc.update(id, patch, { update: true }) (merge fields)
DeleteDoc.delete(id)
Search, filter, sort, page, count, aggregateaggregate, see the Query reference
A natural primary keySet the document ID to a field, for example userId. Writing the same key again updates that record
const profiles = sdk.asAdmin().Insights().Source('App profiles')

const { result } = await profiles.Doc.create({ userId: 'u-1042', theme: 'dark', locale: 'de' })
await profiles.Doc.update(result.id, { locale: 'en' }, { update: true })

const { result: found } = await profiles.aggregate({
size: 1,
filter: [{ term: { 'userId.keyword': 'u-1042' } }]
})

Call it from your backend with a service key (asAdmin). Access is per source, not per record, so keep the key on the server and do the per-user filtering in your own code. The same endpoints are available over REST.

Write from code​

import sdk from '@scenid/cloud-sdk'

const orders = sdk.asAdmin().Insights().Source('Orders')

// one entry
await orders.Doc.create({ orderId: 'ORD-2001', total: 49.8, status: 'paid' })

// many entries
await orders.Doc.batchInsert(rows)

See Push data and Manage documents.

Document ids and duplicates​

The store lets you decide what "the same document" means. In the source settings, Document ID offers:

OptionBehaviour
Automatic (default)Every document gets a random id. Nothing is de-duplicated
FieldThe id is the value of a field you choose, for example orderId. Sending the same key again updates that document (upsert). Re-uploading a file updates existing rows
Decide before the first data arrives

The document id setting can only be changed while the source is empty. The same is true for enrichments. If you plan to re-upload or re-send data and expect updates, choose Field first.

Bodies must be flat, and id and _id are reserved. In batch inserts you can supply your own _id per entry.

Fields and types​

The store starts with no fields. They are created when you upload a file, or you can add them yourself in the Data tab (Add field), and set the types. Detect new fields finds fields that arrived later. Field changes rebuild the typed data from the raw data. See Sources.

Reading​

A store is read like any other source: aggregate, charts and dashboards, CSV export, joins into other sources. See Query data.

Reset​

Reset data in the Data tab removes all documents but keeps the field configuration.

When not to use a store​

  • Data arrives continuously from a broker: use RabbitMQ.
  • Very high volume from your systems, without needing the id back: push.
  • Data already lives in another system that stays the source of truth: BigQuery or Customers.