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.
| Way | Good for |
|---|---|
| The app: create document in the Documents tab | Single entries, corrections, small reference lists |
REST API and SDK: Doc.create, Doc.update, Doc.batchInsert | Your applications writing records programmatically |
| File upload: CSV, JSON, JSONL | Bulk loads, initial data, exports from other tools |
| Repeated uploads | Extending 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.updatereplaces a document, or merges fields withupdate: true.Doc.deleteremoves 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:
- Choose the format: CSV, JSON (an array of objects) or JSONL (one JSON object per line).
- Scenid analyses the file and proposes the fields and their types.
- Fields that already exist in the source are matched automatically. Fields that are new are added to the source.
- 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.
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 need | You use |
|---|---|
| A record by its key | Doc.get(id) |
| Insert | Doc.create(body), Doc.batchInsert(docs) |
| Change a record | Doc.update(id, body) (replace) or Doc.update(id, patch, { update: true }) (merge fields) |
| Delete | Doc.delete(id) |
| Search, filter, sort, page, count, aggregate | aggregate, see the Query reference |
| A natural primary key | Set 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:
| Option | Behaviour |
|---|---|
| Automatic (default) | Every document gets a random id. Nothing is de-duplicated |
| Field | The 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 |
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.