MigrationRepository
Class: MigrationRepository<T>
Defined in: packages/core/src/stores/migrationstore.service.ts:209
Dual-write, phase-switching repository backing MigrationStore.
- While migration is in progress (
!store.isCompleted()):- Reads and queries (
get,exists,query,iterate,count,aggregate) execute againstsource. - Writes execute against
sourcefirst (enforcing write conditions) and copy-on-write the full updated item (or delete) totarget.
- Reads and queries (
- Once migration is completed (
store.isCompleted()):- Reads and queries execute against
target. - Writes execute against
targetfirst (enforcing write conditions) and mirror tosource.
- Reads and queries execute against
Extends
AbstractRepository<T>
Type Parameters
T
T extends ModelClass
Constructors
Constructor
new MigrationRepository<
T>(model,pks,store,separator?):MigrationRepository<T>
Defined in: packages/core/src/stores/migrationstore.service.ts:222
Create a MigrationRepository for a model
Parameters
model
T
model class
pks
(keyof InstanceType<T> & string)[]
primary key field names
store
owning MigrationStore
separator?
string = "#"
composite key separator
Returns
MigrationRepository<T>
Overrides
AbstractRepository<T>.constructor
Properties
aggregationOptions
protectedaggregationOptions:AggregationOptions
Defined in: packages/models/lib/repositories/abstract.d.ts:27
Aggregation fallback policy, set by the owning store through configureAggregation
Inherited from
MemoryRepository.aggregationOptions
events
protectedevents:Map<keyofInstanceType<T>[typeofWEBDA_EVENTS],Set<(data) =>void>>
Defined in: packages/models/lib/repositories/abstract.d.ts:25
Registered event listeners keyed by event name
Inherited from
AbstractRepository.events
maxListeners
protectedmaxListeners:number
Defined in: packages/models/lib/repositories/abstract.d.ts:336
Max-listeners hint kept for Node EventEmitter API compatibility. Not
enforced — repositories use an unbounded Set per event.
Inherited from
model
protectedmodel:T
Defined in: packages/models/lib/repositories/abstract.d.ts:21
Inherited from
AbstractRepository.model
modelId
protectedreadonlymodelId:string
Defined in: packages/core/src/stores/migrationstore.service.ts:213
Model ID
monitorOptions
protectedmonitorOptions:QueryMonitorOptions
Defined in: packages/models/lib/repositories/abstract.d.ts:29
Query monitoring options, set by the owning store through configureMonitoring
Inherited from
MemoryRepository.monitorOptions
pks
protectedpks:string[]
Defined in: packages/models/lib/repositories/abstract.d.ts:22
Inherited from
separator
protectedseparator:string
Defined in: packages/models/lib/repositories/abstract.d.ts:23
Inherited from
store
protectedreadonlystore:MigrationStore
Defined in: packages/core/src/stores/migrationstore.service.ts:225
owning MigrationStore
tableRoot?
protectedoptionaltableRoot?:ModelClass
Defined in: packages/models/lib/repositories/abstract.d.ts:35
Model owning the untyped rows of the storage (the first model of the store), undefined when not known
Inherited from
warnedAggregations
protectedwarnedAggregations:Set<string>
Defined in: packages/models/lib/repositories/abstract.d.ts:31
Fallback shapes already warned about
Inherited from
MemoryRepository.warnedAggregations
Accessors
sourceRepo
Get Signature
get
protectedsourceRepo():AbstractRepository<T>
Defined in: packages/core/src/stores/migrationstore.service.ts:236
Unwrapped repository from the source store
Returns
AbstractRepository<T>
source repository
targetRepo
Get Signature
get
protectedtargetRepo():AbstractRepository<T>
Defined in: packages/core/src/stores/migrationstore.service.ts:244
Unwrapped repository from the target store
Returns
AbstractRepository<T>
target repository
Methods
acceptedTypes()
acceptedTypes():
string[]
Defined in: packages/models/lib/repositories/abstract.d.ts:71
Every stored __type value of this model and its transitive subclasses, for stores filtering in their query
language
Returns
string[]
the values, empty when the model carries no Metadata
Inherited from
AbstractRepository.acceptedTypes
activeReadRepo()
protectedactiveReadRepo():Promise<AbstractRepository<T>>
Defined in: packages/core/src/stores/migrationstore.service.ts:252
Active read/query repository based on migration completion state
Returns
Promise<AbstractRepository<T>>
source repository until completed, target repository once completed
aggregate()
aggregate<
G,M>(spec,params?):Promise<AggregationResult<AggregatedRow<InstanceType<T>,G,M>>>
Defined in: packages/core/src/stores/migrationstore.service.ts:356
Type Parameters
G
G extends readonly _NonFunctionPropertyPaths<InstanceType<T>>[] = []
M
M extends Record<string, MetricSpec<InstanceType<T>>> = Record<string, MetricSpec<InstanceType<T>>>
Parameters
spec
AggregationSpec<InstanceType<T>, G, M>
params?
QueryParameters
Returns
Promise<AggregationResult<AggregatedRow<InstanceType<T>, G, M>>>
Overrides
AbstractRepository.aggregate
aggregateInMemory()
protectedaggregateInMemory(query):Promise<Record<string,unknown>[]>
Defined in: packages/models/lib/repositories/abstract.d.ts:316
Aggregate by streaming the filtered items
Parameters
query
AggregationQuery
the aggregation
Returns
Promise<Record<string, unknown>[]>
the rows
Inherited from
AbstractRepository.aggregateInMemory
applyAssignments()
protectedapplyAssignments<O>(target,assignments):O
Defined in: packages/models/lib/repositories/abstract.d.ts:181
Set the assignments of an UPDATE on an object, creating the intermediate objects of dotted paths
Targets were checked by parseStatement: letters, digits and _ only, no __ segment, no
Object.prototype member name.
Type Parameters
O
O
Parameters
target
O
the object to change in place
assignments
Assignment[]
the SET assignments
Returns
O
the target
Inherited from
AbstractRepository.applyAssignments
belongsToModel()
belongsToModel(
stored?):boolean
Defined in: packages/models/lib/repositories/abstract.d.ts:77
Whether a stored row belongs to this model, for stores filtering in memory
Parameters
stored?
string
the stored __type, undefined for an untyped row
Returns
boolean
true when the row belongs to this model (always without Metadata)
Inherited from
AbstractRepository.belongsToModel
buildItem()
protectedbuildItem(data):InstanceType<T>
Defined in: packages/models/lib/repositories/abstract.d.ts:101
Build the model instance to create from the incoming data
Primary key fields that are undefined or null are dropped from the data so a key generated by the model constructor (e.g. UuidModel) is not overwritten. Repositories must read the storage key from the returned instance.
Parameters
data
Helpers<InstanceType<T>>
the incoming data
Returns
InstanceType<T>
the model instance
Inherited from
AbstractRepository.buildItem
checkAggregationFallback()
protectedcheckAggregationFallback(query,reason):Promise<void>
Defined in: packages/models/lib/repositories/abstract.d.ts:287
Apply the fallback policy before aggregating or counting in memory
Parameters
query
AggregationQuery
the aggregation, undefined for a count
reason
string
why it cannot run natively
Returns
Promise<void>
Throws
AggregationError AGGREGATION_NOT_NATIVE when the policy is deny
Inherited from
AbstractRepository.checkAggregationFallback
collectStatementKeys()
protectedcollectStatementKeys(statement):Promise<PrimaryKeyType<InstanceType<T>>[]>
Defined in: packages/models/lib/repositories/abstract.d.ts:188
Keys of the objects matching the WHERE of a statement, collected before any change so an update changing a WHERE field cannot meet the same object twice; at most LIMIT keys
Parameters
statement
Query
the parsed statement
Returns
Promise<PrimaryKeyType<InstanceType<T>>[]>
the primary keys
Inherited from
AbstractRepository.collectStatementKeys
configureAggregation()
configureAggregation(
options):void
Defined in: packages/models/lib/repositories/abstract.d.ts:243
Copy the known options (fallback, maxGroups, warn); undefined values keep the current ones
Parameters
options
Partial<AggregationOptions>
Returns
void
Throws
Error when maxGroups is not a positive integer or fallback is unknown
Inherited from
AbstractRepository.configureAggregation
configureMonitoring()
configureMonitoring(
options):void
Defined in: packages/models/lib/repositories/abstract.d.ts:248
Configure the query monitoring policy, called by the owning store
Parameters
options
Partial<QueryMonitorOptions>
options to override
Returns
void
Inherited from
AbstractRepository.configureMonitoring
count()
count(
filter?,params?,options?):Promise<CountResult>
Defined in: packages/core/src/stores/migrationstore.service.ts:350
Parameters
filter?
string
params?
QueryParameters
options?
Returns
Promise<CountResult>
Overrides
AbstractRepository.count
countInMemory()
protectedcountInMemory(filter,max?):Promise<Omit<CountResult,"native">>
Defined in: packages/models/lib/repositories/abstract.d.ts:310
Count by streaming the filtered items, stopping at max + 1
Parameters
filter
Expression
the filter
max?
number
stop after max objects, undefined for an exact count
Returns
Promise<Omit<CountResult, "native">>
the value and its relation
Inherited from
AbstractRepository.countInMemory
create()
create(
data,save?):Promise<InstanceType<T>>
Defined in: packages/core/src/stores/migrationstore.service.ts:368
Parameters
data
Helpers<InstanceType<T>>
save?
boolean
Returns
Promise<InstanceType<T>>
Overrides
AbstractRepository.create
delete()
delete<
K>(uuid,conditionField?,condition?):Promise<void>
Defined in: packages/core/src/stores/migrationstore.service.ts:392
Type Parameters
K
K extends string
Parameters
uuid
PrimaryKeyType<InstanceType<T>>
conditionField?
K
condition?
PropertyPathType<InstanceType<T>, K> | JSONed<PropertyPathType<InstanceType<T>, K>>
Returns
Promise<void>
Overrides
AbstractRepository.delete
deleteItemFromCollection()
deleteItemFromCollection<
K,L>(uuid,collection,index,itemWriteConditionField?,itemWriteCondition?):Promise<void>
Defined in: packages/core/src/stores/migrationstore.service.ts:451
Type Parameters
K
K extends string
L
L extends string | number | symbol
Parameters
uuid
PrimaryKeyType<InstanceType<T>>
collection
K
index
number
itemWriteConditionField?
L
itemWriteCondition?
ArrayElement<InstanceType<T>[K]>[L]
Returns
Promise<void>
Overrides
AbstractRepository.deleteItemFromCollection
deleteMany()
deleteMany(
statement,params?):Promise<number>
Defined in: packages/models/lib/repositories/abstract.d.ts:224
Delete in bulk: see Repository.deleteMany
The generic implementation collects the matching keys then deletes them with delete; stores override it
with their native batch operation.
Parameters
statement
string | Query
params?
QueryParameters
Returns
Promise<number>
Inherited from
AbstractRepository.deleteMany
deleteManyByKey()
protecteddeleteManyByKey(statement,params?):Promise<number>
Defined in: packages/models/lib/repositories/abstract.d.ts:206
Generic deleteMany: collect the matching keys (up to LIMIT), then delete them one by one with this
repository's delete primitive
Used by stores without a native bulk delete. On a store repository the primitive emits no event.
Parameters
statement
string | Query
the DELETE statement or its parsed form
params?
QueryParameters
values for the placeholders
Returns
Promise<number>
the number of objects deleted
Inherited from
AbstractRepository.deleteManyByKey
emit()
emit<
K>(event,data):Promise<void>
Defined in: packages/models/lib/repositories/abstract.d.ts:361
Emit an event to all registered listeners and await their completion.
Type Parameters
K
K extends string | number | symbol
Parameters
event
K
The event name to emit
data
InstanceType<T>[typeof WEBDA_EVENTS][K]
The event payload
Returns
Promise<void>
Inherited from
AbstractRepository.emit
excludePrimaryKey()
excludePrimaryKey(
object):any
Defined in: packages/models/lib/repositories/abstract.d.ts:125
Parameters
object
any
Returns
any
Inherited from
AbstractRepository.excludePrimaryKey
executeAggregation()
protectedexecuteAggregation(query):Promise<AggregationResult<any>>
Defined in: packages/models/lib/repositories/abstract.d.ts:280
Run a validated aggregation
Backends override it to aggregate natively, and call super for the shapes they cannot translate. The default streams iterate() into the in-memory Aggregator, under the fallback policy.
Parameters
query
AggregationQuery
the validated aggregation
Returns
Promise<AggregationResult<any>>
the rows
Inherited from
AbstractRepository.executeAggregation
executeCount()
protectedexecuteCount(filter,max?):Promise<CountResult>
Defined in: packages/models/lib/repositories/abstract.d.ts:303
Count the objects matching a validated filter
Backends override it to count natively. The default scans iterate() in memory, under the fallback policy. It does not go through executeAggregation: an aggregation has no cap.
Parameters
filter
Expression
the filter, without ORDER BY, LIMIT or OFFSET
max?
number
stop after max objects, undefined for an exact count
Returns
Promise<CountResult>
the count
Inherited from
AbstractRepository.executeCount
exists()
exists(
uuid):Promise<boolean>
Defined in: packages/core/src/stores/migrationstore.service.ts:327
Parameters
uuid
PrimaryKeyType<InstanceType<T>>
Returns
Promise<boolean>
Overrides
AbstractRepository.exists
fromUID()
fromUID(
uid):ModelRefWithCreate<InstanceType<T>>
Defined in: packages/models/lib/repositories/abstract.d.ts:107
Return a ref from the uuid
Parameters
uid
string
the serialized primary key
Returns
ModelRefWithCreate<InstanceType<T>>
a model reference with create capability
Inherited from
AbstractRepository.fromUID
get()
get(
primaryKey):Promise<HelperProperties<InstanceType<T>>>
Defined in: packages/core/src/stores/migrationstore.service.ts:321
Parameters
primaryKey
PrimaryKeyType<InstanceType<T>>
Returns
Promise<HelperProperties<InstanceType<T>>>
Overrides
AbstractRepository.get
getAllowedFields()
getAllowedFields():
string[]
Defined in: packages/models/lib/repositories/abstract.d.ts:153
Field paths of the model, from its metadata (Reflection and the stored, input and output schemas)
Used to validate UPDATE SET targets.
Returns
string[]
the field names, undefined when the model carries no field metadata (no validation then)
Inherited from
AbstractRepository.getAllowedFields
getCompletionFields()
getCompletionFields():
CompletionField[]
Defined in: packages/models/lib/repositories/abstract.d.ts:158
Completion fields of the model, flattened from its schemas
Returns
CompletionField[]
array of completion fields
Inherited from
AbstractRepository.getCompletionFields
getMaxListeners()
getMaxListeners():
number
Defined in: packages/models/lib/repositories/abstract.d.ts:349
EventEmitter-compatibility shim. Returns the max-listeners hint.
Returns
number
the current max-listeners hint
Inherited from
AbstractRepository.getMaxListeners
getPrimaryKey()
Call Signature
getPrimaryKey(
object,forceObject?):PrimaryKeyType<InstanceType<T>>
Defined in: packages/models/lib/repositories/abstract.d.ts:127
Get the primary key value for an object as a scalar or string.
Parameters
object
any
forceObject?
false
Returns
PrimaryKeyType<InstanceType<T>>
Inherited from
AbstractRepository.getPrimaryKey
Call Signature
getPrimaryKey(
object,forceObject):PrimaryKey<InstanceType<T>>
Defined in: packages/models/lib/repositories/abstract.d.ts:129
Get the primary key value for an object as a structured key object.
Parameters
object
any
forceObject
true
Returns
PrimaryKey<InstanceType<T>>
Inherited from
AbstractRepository.getPrimaryKey
getRootModel()
getRootModel():
T
Defined in: packages/models/lib/repositories/abstract.d.ts:48
Returns
T
Inherited from
AbstractRepository.getRootModel
getTableRoot()
getTableRoot():
ModelClass<Storable<any,any>>
Defined in: packages/models/lib/repositories/abstract.d.ts:59
Get the model owning the untyped rows of the storage
Returns
ModelClass<Storable<any, any>>
the model owning the untyped rows of the storage
Inherited from
AbstractRepository.getTableRoot
getUID()
getUID(
object):string
Defined in: packages/models/lib/repositories/abstract.d.ts:131
Parameters
object
any
Returns
string
Inherited from
AbstractRepository.getUID
incrementAttribute()
incrementAttribute<
K,L>(primaryKey,info,_conditionField?,_condition?):Promise<void>
Defined in: packages/models/lib/repositories/abstract.d.ts:139
Type Parameters
K
K extends string
L
L extends string
Parameters
primaryKey
PK<InstanceType<T>, InstanceType<T>[typeof WEBDA_PRIMARY_KEY][number]>
info
L | { property: L; value?: number; }
_conditionField?
K
_condition?
any
Returns
Promise<void>
Inherited from
AbstractRepository.incrementAttribute
incrementAttributes()
incrementAttributes<
K,L>(primaryKey,info,conditionField?,condition?):Promise<void|Record<string,number>>
Defined in: packages/core/src/stores/migrationstore.service.ts:410
Type Parameters
K
K extends string
L
L extends string
Parameters
primaryKey
PK<InstanceType<T>, InstanceType<T>[typeof WEBDA_PRIMARY_KEY][number]>
info
(L | { property: L; value?: number; })[] | Record<L, number>
conditionField?
K
condition?
unknown
Returns
Promise<void | Record<string, number>>
Overrides
AbstractRepository.incrementAttributes
iterate()
iterate(
query?,params?):AsyncGenerator<InstanceType<T>,void,unknown>
Defined in: packages/core/src/stores/migrationstore.service.ts:342
Parameters
query?
string = ""
params?
QueryParameters
Returns
AsyncGenerator<InstanceType<T>, void, unknown>
Overrides
AbstractRepository.iterate
legacyTypeRewrites()
protectedlegacyTypeRewrites():Record<string,string>
Defined in: packages/models/lib/repositories/abstract.d.ts:90
Stored types a write of this model family rewrites, for stores updating rows in place: each form of a model (current, short, lower-case, alias) to its current identifier, and the ancestor types of the table root to the table root identifier
Returns
Record<string, string>
the current identifier by lower-cased stored type, empty when the model carries no Metadata
Inherited from
AbstractRepository.legacyTypeRewrites
mirrorMutation()
protectedmirrorMutation<R>(primaryKey,mutate):Promise<R>
Defined in: packages/core/src/stores/migrationstore.service.ts:303
Execute an in-place mutation on the primary repository and copy-on-write the full resulting item to the secondary repository
Type Parameters
R
R
Parameters
primaryKey
PrimaryKeyType<InstanceType<T>>
primary key of the mutated item
mutate
(repo) => Promise<R>
mutation callback executed against the primary repository
Returns
Promise<R>
result of the primary mutation
mirrorWrite()
protectedmirrorWrite(write):Promise<InstanceType<T>>
Defined in: packages/core/src/stores/migrationstore.service.ts:281
Execute a create/upsert write on the primary repository and mirror the resulting item to the secondary repository
Parameters
write
(repo) => Promise<InstanceType<T>>
write callback executed against the primary repository
Returns
Promise<InstanceType<T>>
the created or upserted model instance
monitor()
protectedmonitor<R>(operation,query,fn,details):Promise<R>
Defined in: packages/models/lib/repositories/abstract.d.ts:262
Helper that times a query operation, catches and rethrows errors, and calls onQuery safely
Type Parameters
R
R
Parameters
operation
QueryOperation
the query operation
query
string
the query string
fn
() => Promise<R>
the async function to execute and time
details
((r) => object) | ((r) => number)
optional callback to extract result count or pagination details
Returns
Promise<R>
the result of fn
Inherited from
AbstractRepository.monitor
off()
off<
K>(event,listener):void
Defined in: packages/models/lib/repositories/abstract.d.ts:331
Type Parameters
K
K extends string | number | symbol
Parameters
event
K
listener
(data) => void
Returns
void
Inherited from
AbstractRepository.off
on()
on<
K>(event,listener):void
Defined in: packages/models/lib/repositories/abstract.d.ts:327
Type Parameters
K
K extends string | number | symbol
Parameters
event
K
listener
(data) => void
Returns
void
Inherited from
AbstractRepository.on
once()
once<
K>(event,listener):void
Defined in: packages/models/lib/repositories/abstract.d.ts:329
Type Parameters
K
K extends string | number | symbol
Parameters
event
K
listener
(data) => void
Returns
void
Inherited from
AbstractRepository.once
parseLegacyUID()
protectedparseLegacyUID(uid):PrimaryKey<InstanceType<T>>
Defined in: packages/models/lib/repositories/abstract.d.ts:123
Parse a uid through the model's parseLegacyUID hook
Parameters
uid
string
the raw storage key
Returns
PrimaryKey<InstanceType<T>>
a key whose string form is the raw uid, or undefined when the model does not recognise it
Inherited from
AbstractRepository.parseLegacyUID
parseStatement()
protectedparseStatement(type,statement,params?):Promise<Query>
Defined in: packages/models/lib/repositories/abstract.d.ts:171
Parse a bulk statement and check it is of the expected type
For an UPDATE, every SET target is checked: no primary key field, no private (__) segment, no
constructor/prototype segment, and a field of the model when its metadata lists them.
Parameters
type
"DELETE" | "UPDATE"
the expected statement type
statement
string | Query
the statement string or its parsed form
params?
QueryParameters
values for the placeholders of a statement string
Returns
Promise<Query>
the parsed statement
Throws
WebdaQLError when the statement has another type or a SET target is refused
Throws
SyntaxError when the statement does not parse, or a SET target is not a field of the model
Inherited from
AbstractRepository.parseStatement
parseUID()
parseUID(
uid,forceObject?):PrimaryKeyType<InstanceType<T>> |PrimaryKey<InstanceType<T>>
Defined in: packages/models/lib/repositories/abstract.d.ts:117
Parse a serialized primary key
A composite key that does not split into the primary key fields is offered to the model's optional
static parseLegacyUID(uid) hook (see WEBDA_LEGACY_UID): the returned key keeps the raw uid as its
string form so it addresses the legacy storage entry. Without a hook, or when the hook declines, the
uid is rejected.
Parameters
uid
string
forceObject?
boolean
Returns
PrimaryKeyType<InstanceType<T>> | PrimaryKey<InstanceType<T>>
Inherited from
AbstractRepository.parseUID
patch()
patch<
K>(primaryKey,data,conditionField?,condition?):Promise<void>
Defined in: packages/core/src/stores/migrationstore.service.ts:382
Type Parameters
K
K extends string
Parameters
primaryKey
PK<InstanceType<T>, InstanceType<T>[typeof WEBDA_PRIMARY_KEY][number]>
data
Partial<InstanceType<T>>
conditionField?
K
condition?
unknown
Returns
Promise<void>
Overrides
AbstractRepository.patch
query()
query(
query,params?):Promise<{continuationToken?:string;results:InstanceType<T>[]; }>
Defined in: packages/core/src/stores/migrationstore.service.ts:333
Parameters
query
string
params?
QueryParameters
Returns
Promise<{ continuationToken?: string; results: InstanceType<T>[]; }>
Overrides
AbstractRepository.query
ref()
ref(
key):ModelRefWithCreate<InstanceType<T>>
Defined in: packages/models/lib/repositories/abstract.d.ts:137
Parameters
key
PK<InstanceType<T>, InstanceType<T>[typeof WEBDA_PRIMARY_KEY][number]>
Returns
ModelRefWithCreate<InstanceType<T>>
Inherited from
AbstractRepository.ref
removeAttribute()
removeAttribute<
L,K>(uuid,attribute,conditionField?,condition?):Promise<void>
Defined in: packages/core/src/stores/migrationstore.service.ts:422
Type Parameters
L
L extends string
K
K extends string
Parameters
uuid
PrimaryKeyType<InstanceType<T>>
attribute
K
conditionField?
L
condition?
PropertyPathType<InstanceType<T>, L> | JSONed<PropertyPathType<InstanceType<T>, L>>
Returns
Promise<void>
Overrides
AbstractRepository.removeAttribute
removeListener()
removeListener<
K>(event,listener):void
Defined in: packages/models/lib/repositories/abstract.d.ts:344
EventEmitter-compatibility alias for off. Consumers that treat a
repository as a Node EventEmitter (e.g. @webda/runtime EventIterator)
call removeListener.
Type Parameters
K
K extends string | number | symbol
Parameters
event
K
the event name
listener
(data) => void
the listener to remove
Returns
void
Inherited from
AbstractRepository.removeListener
safeOnQuery()
protectedsafeOnQuery(info):void
Defined in: packages/models/lib/repositories/abstract.d.ts:253
Safely invoke the onQuery callback without throwing into the caller
Parameters
info
QueryExecutionInfo
query execution info
Returns
void
Inherited from
AbstractRepository.safeOnQuery
setAttribute()
setAttribute<
K,L>(primaryKey,attribute,value,conditionField?,condition?):Promise<void>
Defined in: packages/models/lib/repositories/abstract.d.ts:135
Type Parameters
K
K extends string
L
L extends string
Parameters
primaryKey
string | PK<InstanceType<T>, InstanceType<T>[typeof WEBDA_PRIMARY_KEY][number]>
attribute
K
value
_PropertyPathType<InstanceType<T>, K>
conditionField?
L
condition?
_PropertyPathType<InstanceType<T>, L> | JSONed<_PropertyPathType<InstanceType<T>, L>>
Returns
Promise<void>
Inherited from
AbstractRepository.setAttribute
setMaxListeners()
setMaxListeners(
n):this
Defined in: packages/models/lib/repositories/abstract.d.ts:355
EventEmitter-compatibility shim. Records the max-listeners hint (no enforcement).
Parameters
n
number
the new hint value
Returns
this
this for chaining
Inherited from
AbstractRepository.setMaxListeners
setTableRoot()
setTableRoot(
root?):this
Defined in: packages/models/lib/repositories/abstract.d.ts:54
Set the model owning the untyped rows of the storage
Parameters
root?
the first model of the store, undefined when not known
Returns
this
this
Inherited from
AbstractRepository.setTableRoot
syncFullItem()
protectedsyncFullItem(repo,pk,full):Promise<void>
Defined in: packages/core/src/stores/migrationstore.service.ts:264
Synchronize a full item snapshot into a mirror repository, replacing any existing entry so removed attributes do not linger behind a shallow patch
Parameters
repo
AbstractRepository<T>
destination repository
pk
PrimaryKeyType<InstanceType<T>>
primary key of the item
full
Helpers<InstanceType<T>>
full item snapshot
Returns
Promise<void>
tableRootAncestorTypes()
protectedtableRootAncestorTypes():string[]
Defined in: packages/models/lib/repositories/abstract.d.ts:83
Stored types naming a strict ancestor of the table root (e.g. UuidModel in a table of an application model),
for stores filtering in their query language: such rows belong to the table root, like untyped rows
Returns
string[]
the types, empty when the table root is unknown or this model does not own the untyped rows
Inherited from
AbstractRepository.tableRootAncestorTypes
typeResolver()
protectedtypeResolver():ModelTypeResolver
Defined in: packages/models/lib/repositories/abstract.d.ts:65
Resolver of the stored __type: the installed application one when it knows the model, else the model's own
hierarchy with exact identifiers only
Returns
the resolver
Inherited from
AbstractRepository.typeResolver
update()
update<
K>(data,conditionField?,condition?):Promise<void>
Defined in: packages/core/src/stores/migrationstore.service.ts:373
Type Parameters
K
K extends string
Parameters
data
Helpers<InstanceType<T>>
conditionField?
K
condition?
PropertyPathType<InstanceType<T>, K>
Returns
Promise<void>
Overrides
AbstractRepository.update
updateMany()
updateMany(
statement,params?):Promise<number>
Defined in: packages/models/lib/repositories/abstract.d.ts:232
Update in bulk: see Repository.updateMany
The generic implementation collects the matching keys then patches them with patch; stores override it
with their native batch operation.
Parameters
statement
string | Query
params?
QueryParameters
Returns
Promise<number>
Inherited from
AbstractRepository.updateMany
updateManyByKey()
protectedupdateManyByKey(statement,params?):Promise<number>
Defined in: packages/models/lib/repositories/abstract.d.ts:216
Generic updateMany: collect the matching keys (up to LIMIT), then patch them one by one with this
repository's patch primitive. A dotted target reads the object to rewrite its top-level field.
Used by stores without a native bulk update. On a store repository the primitive emits no event.
Parameters
statement
string | Query
the UPDATE statement or its parsed form
params?
QueryParameters
values for the placeholders
Returns
Promise<number>
the number of objects updated
Inherited from
AbstractRepository.updateManyByKey
upsert()
upsert(
data):Promise<InstanceType<T>>
Defined in: packages/models/lib/repositories/abstract.d.ts:133
Parameters
data
Helpers<InstanceType<T>>
Returns
Promise<InstanceType<T>>
Inherited from
AbstractRepository.upsert
upsertItemToCollection()
upsertItemToCollection<
K,L>(uuid,collection,item,index?,itemWriteConditionField?,itemWriteCondition?):Promise<void>
Defined in: packages/core/src/stores/migrationstore.service.ts:432
Type Parameters
K
K extends string
L
L extends string | number | symbol
Parameters
uuid
PrimaryKeyType<InstanceType<T>>
collection
K
item
ArrayElement<InstanceType<T>[K]> | JSONed<ArrayElement<InstanceType<T>[K]>>
index?
number
itemWriteConditionField?
ArrayElement<InstanceType<T>[K]> extends object ? L : never
itemWriteCondition?
ArrayElement<InstanceType<T>[K]> extends object ? object & ArrayElement[L] : ArrayElement<InstanceType<T>[K]>
Returns
Promise<void>
Overrides
AbstractRepository.upsertItemToCollection
writeIfPresent()
protectedwriteIfPresent(key,write):Promise<boolean>
Defined in: packages/models/lib/repositories/abstract.d.ts:196
Run one write of the generic fallback; an object deleted since the keys were collected is skipped
Parameters
key
PrimaryKeyType<InstanceType<T>>
the primary key
write
() => Promise<void>
the write
Returns
Promise<boolean>
true when written, false when the object is gone
Throws
the write error when the object still exists
Inherited from
AbstractRepository.writeIfPresent