Primitive
atom.findOrCreate
BETAShort name: findOrCreate
Version: 1.0.0
Idempotently return the caller's own atom matching `matchData`, creating it from `data`/`lexemeIds` when absent. Concurrent duplicate creates collapse to a single atom via the owner+namespace+slug partial unique index.
Back to primitive libraryInputs
| Key | Type | Required | Description |
|---|---|---|---|
| data | object | false | Field map for the new atom when none matches. Each entry is a FieldEntry (see Atom model). |
| isPublic | boolean | false | Whether a newly created atom is publicly readable. |
| lexemeIds | array<objectId> | false | Lexemes the new atom subscribes to. Caller must have read access to each. |
| matchData | object | true | Map of top-level data field name to primitive value used to locate an existing owned atom (matched against data.<field>.value). |
| ownerOrganizationAtomId | objectId|null | false | Organization atom that owns a newly created atom. Caller must be a member or admin. |
Outputs
| Key | Type | Required | Description |
|---|---|---|---|
| atom | object | false | The matched-or-created atom summary: { id, version, lexemeIds, data, isPublic }. |
| created | boolean | false | True when a new atom was inserted; false when an existing atom was returned (including after losing a create race). |
| dataDriftReport | object | false | Optional non-blocking lexeme/data drift diagnostics, only present on a fresh create. |