SocialluxSociallux
Toggle navigation menu
Docs navigationv

Primitive

atom.findOrCreate

BETA

Short 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 library

Inputs

KeyTypeRequiredDescription
dataobjectfalseField map for the new atom when none matches. Each entry is a FieldEntry (see Atom model).
isPublicbooleanfalseWhether a newly created atom is publicly readable.
lexemeIdsarray<objectId>falseLexemes the new atom subscribes to. Caller must have read access to each.
matchDataobjecttrueMap of top-level data field name to primitive value used to locate an existing owned atom (matched against data.<field>.value).
ownerOrganizationAtomIdobjectId|nullfalseOrganization atom that owns a newly created atom. Caller must be a member or admin.

Outputs

KeyTypeRequiredDescription
atomobjectfalseThe matched-or-created atom summary: { id, version, lexemeIds, data, isPublic }.
createdbooleanfalseTrue when a new atom was inserted; false when an existing atom was returned (including after losing a create race).
dataDriftReportobjectfalseOptional non-blocking lexeme/data drift diagnostics, only present on a fresh create.