TypeIndexedMap
Class: TypeIndexedMap<V>
Defined in: packages/models/src/repositories/typeindexedmap.ts:32
Storage map of a MemoryRepository indexing its entries by stored __type
Every model of a MemoryStore shares one storage map: without an index, a query parses every document of the
store to find the ones of its model. This map keeps, for each stored __type, the keys holding it, so
MemoryRepository.query only visits the entries of its model and subclasses.
The index is lazy: a write only records the key, its __type is read (one JSON.parse) the first time a query
needs it. Every write path goes through set / delete / clear — repositories, persistence reload, raw
patches of migrations — so the index can never miss an entry.
keysOfTypes returns the keys in the map insertion order, as iterating the map does: query results and offset continuation tokens are unchanged.
Extends
Map<string,V>
Type Parameters
V
V = string
Constructors
Constructor
new TypeIndexedMap<
V>(entries?):TypeIndexedMap<V>
Defined in: packages/models/src/repositories/typeindexedmap.ts:48
Create a new TypeIndexedMap instance
Parameters
entries?
Iterable<readonly [string, V], any, any> | null
initial entries
Returns
TypeIndexedMap<V>
Overrides
Map<string, V>.constructor
Properties
[toStringTag]
readonly[toStringTag]:string
Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts:135
Inherited from
Map.[toStringTag]
size
readonlysize:number
Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2015.collection.d.ts:46
Returns
the number of elements in the Map.
Inherited from
Map.size
[species]
readonlystatic[species]:MapConstructor
Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts:317
Inherited from
Map.[species]
Methods
[iterator]()
[iterator]():
MapIterator<[string,V]>
Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2015.iterable.d.ts:141
Returns an iterable of entries in the map.
Returns
MapIterator<[string, V]>
Inherited from
Map.[iterator]
clear()
clear():
void
Defined in: packages/models/src/repositories/typeindexedmap.ts:99
Delete every entry
Returns
void
Overrides
Map.clear
delete()
delete(
key):boolean
Defined in: packages/models/src/repositories/typeindexedmap.ts:89
Delete an entry
Parameters
key
string
the key
Returns
boolean
true when the entry existed
Overrides
Map.delete
entries()
entries():
MapIterator<[string,V]>
Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2015.iterable.d.ts:146
Returns an iterable of key, value pairs for every entry in the map.
Returns
MapIterator<[string, V]>
Inherited from
Map.entries
forEach()
forEach(
callbackfn,thisArg?):void
Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2015.collection.d.ts:29
Executes a provided function once per each key/value pair in the Map, in insertion order.
Parameters
callbackfn
(value, key, map) => void
thisArg?
any
Returns
void
Inherited from
Map.forEach
get()
get(
key):V|undefined
Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2015.collection.d.ts:34
Returns a specified element from the Map object. If the value that is associated to the provided key is an object, then you will get a reference to that object and any change made to that object will effectively modify it inside the Map.
Parameters
key
string
Returns
V | undefined
Returns the element associated with the specified key. If no element is associated with the specified key, undefined is returned.
Inherited from
Map.get
getOrInsert()
getOrInsert(
key,defaultValue):V
Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.esnext.collection.d.ts:25
Returns a specified element from the Map object.
If no element is associated with the specified key, a new element with the value defaultValue will be inserted into the Map and returned.
Parameters
key
string
defaultValue
V
Returns
V
The element associated with the specified key, which will be defaultValue if no element previously existed.
Inherited from
Map.getOrInsert
getOrInsertComputed()
getOrInsertComputed(
key,callback):V
Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.esnext.collection.d.ts:31
Returns a specified element from the Map object.
If no element is associated with the specified key, the result of passing the specified key to the callback function will be inserted into the Map and returned.
Parameters
key
string
callback
(key) => V
Returns
V
The element associated with the specific key, which will be the newly computed value if no element previously existed.
Inherited from
Map.getOrInsertComputed
has()
has(
key):boolean
Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2015.collection.d.ts:38
Parameters
key
string
Returns
boolean
boolean indicating whether an element with the specified key exists or not.
Inherited from
Map.has
keys()
keys():
MapIterator<string>
Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2015.iterable.d.ts:151
Returns an iterable of keys in the map
Returns
MapIterator<string>
Inherited from
Map.keys
keysOfTypes()
keysOfTypes(
accept):string[]
Defined in: packages/models/src/repositories/typeindexedmap.ts:170
Keys whose stored __type is accepted, in map insertion order
Unreadable entries (not JSON, not a string) are always returned so the error of reading them surfaces.
Parameters
accept
(type) => boolean
whether entries of a stored type are wanted, called once per distinct type, with undefined for untyped entries
Returns
string[]
the keys
set()
set(
key,value):this
Defined in: packages/models/src/repositories/typeindexedmap.ts:75
Set an entry: its type is indexed on the next read
Parameters
key
string
the key
value
V
the stored value
Returns
this
this
Overrides
Map.set
values()
values():
MapIterator<V>
Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2015.iterable.d.ts:156
Returns an iterable of values in the map
Returns
MapIterator<V>
Inherited from
Map.values
groupBy()
staticgroupBy<K,T>(items,keySelector):Map<K,T[]>
Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2024.collection.d.ts:23
Groups members of an iterable according to the return value of the passed callback.
Type Parameters
K
K
T
T
Parameters
items
Iterable<T>
An iterable.
keySelector
(item, index) => K
A callback which will be invoked for each item in items.
Returns
Map<K, T[]>
Inherited from
Map.groupBy