LogoRobo.js
Framework

FlashcoreModel<T>

Class: FlashcoreModel<T>

FlashcoreModel class.

Provides CRUD operations for a model defined by a schema.

Type Parameters

Type ParameterDefault type
T extends { id: string; }{ id: string; }

Constructors

new FlashcoreModel()

new FlashcoreModel<T>(
   name, 
   schemaFields, 
   adapter, 
options?): FlashcoreModel<T>

Parameters

ParameterType
namestring
schemaFieldsSchemaFields
adapterFlashcoreAdapter<string, unknown>
options?FlashcoreModelOptions

Returns

FlashcoreModel<T>

Properties

PropertyModifierTypeDefault valueDescription
hooks?readonlyModelHooks<T>undefined-
metareadonlyRecord<string, unknown>{}Plugin metadata storage.
namereadonlystringundefined-
namespace?readonlystringundefined-
schemareadonlyNormalizedSchemaundefined-

Methods

count()

count(args?): Promise<number>

Get the record count, optionally with filtering.

Parameters

ParameterTypeDescription
args?CountArgs<T>Optional count arguments with where clause

Returns

Promise<number>

Count of matching records


create()

create(data): Promise<T>

Create a new record.

Parameters

ParameterTypeDescription
dataCreateInput<T>Record data (id is auto-generated if not provided)

Returns

Promise<T>

Created record


createMany()

createMany(args): Promise<CreateManyResult<T>>

Create multiple records atomically. Requires adapter with ACID support (transaction or atomicBatch).

Parameters

ParameterTypeDescription
argsCreateManyArgs<T>Create many arguments with data array

Returns

Promise<CreateManyResult<T>>

Created records array


delete()

delete(args): Promise<T>

Delete a record.

Parameters

ParameterTypeDescription
argsDeleteArgs<T>Delete arguments with where clause

Returns

Promise<T>

Deleted record or null if not found


deleteMany()

deleteMany(args): Promise<BatchResult>

Delete multiple records atomically. Requires adapter with ACID support (transaction or atomicBatch).

Parameters

ParameterTypeDescription
argsDeleteManyArgs<T>Delete many arguments with where clause

Returns

Promise<BatchResult>

Batch result with count of deleted records


findFirst()

findFirst(args?): Promise<T>

Find the first matching record.

Parameters

ParameterTypeDescription
args?FindFirstArgs<T>FindFirst arguments

Returns

Promise<T>

First matching record or null


findMany()

findMany(args?): Promise<T[]>

Find multiple records with filtering, ordering, and pagination.

Parameters

ParameterTypeDescription
args?FindManyArgs<T>FindMany arguments

Returns

Promise<T[]>

Array of matching records


findManyStream()

findManyStream(args?): AsyncGenerator<T, void, undefined>

Stream records for memory-efficient processing.

Parameters

ParameterTypeDescription
args?FindManyArgs<T>FindMany arguments

Returns

AsyncGenerator<T, void, undefined>

Yields

Records one by one


findUnique()

findUnique(args): Promise<T>

Find a unique record by ID or unique field.

Parameters

ParameterTypeDescription
argsFindUniqueArgs<T>Find arguments with where clause

Returns

Promise<T>

Found record or null


getIndexedFields()

getIndexedFields(): string[]

Get indexed field names.

Returns

string[]


getRelations()

getRelations(): RelationDef[]

Get relation definitions.

Returns

RelationDef[]


getSchema()

getSchema(): Map<string, {
  indexed: boolean;
  name: string;
  optional: boolean;
  primaryKey: boolean;
  type: string;
  unique: boolean;
}>

Get the raw schema fields.

Returns

Map<string, { indexed: boolean; name: string; optional: boolean; primaryKey: boolean; type: string; unique: boolean; }>


getSchemaChecksum()

getSchemaChecksum(): string

Get the schema checksum.

Returns

string


getUniqueFields()

getUniqueFields(): string[]

Get unique field names.

Returns

string[]


pluginContext()

pluginContext(pluginName): PluginContext

Get plugin context by name.

Used by plugins to access their state and methods from model operations.

Parameters

ParameterTypeDescription
pluginNamestringName of the plugin

Returns

PluginContext

Plugin context

Throws

Error if plugin not found


update()

update(args): Promise<T>

Update a record.

Parameters

ParameterTypeDescription
argsUpdateArgs<T>Update arguments with where and data

Returns

Promise<T>

Updated record or null if not found


updateMany()

updateMany(args): Promise<BatchResult>

Update multiple records atomically. Requires adapter with ACID support (transaction or atomicBatch).

Parameters

ParameterTypeDescription
argsUpdateManyArgs<T>Update many arguments with where clause and data

Returns

Promise<BatchResult>

Batch result with count of updated records


upsert()

upsert(args): Promise<T>

Create or update a record based on unique identifier.

Parameters

ParameterTypeDescription
argsUpsertArgs<T>Upsert arguments with where, create, and update data

Returns

Promise<T>

Created or updated record

On this page