MCPcopy Create free account
hub / github.com/mikro-orm/mikro-orm / syncCollections

Function syncCollections

packages/core/src/drivers/DatabaseDriver.ts:165–191  ·  view source on GitHub ↗
(
    collections: Iterable<Collection<T, O>>,
    options?: DriverMethodOptions,
  )

Source from the content-addressed store, hash-verified

163 }
164
165 async syncCollections<T extends object, O extends object>(
166 collections: Iterable<Collection<T, O>>,
167 options?: DriverMethodOptions,
168 ): Promise<void> {
169 for (const coll of collections) {
170 /* v8 ignore else */
171 if (!coll.property.owner) {
172 if (coll.getSnapshot() === undefined) {
173 throw ValidationError.cannotModifyInverseCollection(coll.owner, coll.property);
174 }
175
176 continue;
177 }
178
179 /* v8 ignore next */
180 {
181 const pk = coll.property.targetMeta!.primaryKeys[0];
182 const data = { [coll.property.name]: coll.getIdentifiers(pk) } as EntityData<T>;
183 await this.nativeUpdate<T>(
184 coll.owner.constructor,
185 helper(coll.owner).getPrimaryKey() as FilterQuery<T>,
186 data,
187 options,
188 );
189 }
190 }
191 }
192
193 /** Maps raw database result to entity data, converting column names to property names. */
194 mapResult<T extends object>(

Callers

nothing calls this directly

Calls 5

helperFunction · 0.85
getSnapshotMethod · 0.80
getIdentifiersMethod · 0.80
getPrimaryKeyMethod · 0.65

Tested by

no test coverage detected