* Ensures the collection is loaded first (without reloading it if it already is loaded). * Returns the Collection instance (itself), works the same as `Reference.load()`.
(
options: InitCollectionOptions<TT, P> = {},
)
| 101 | * Returns the Collection instance (itself), works the same as `Reference.load()`. |
| 102 | */ |
| 103 | async load<TT extends T, P extends string = never>( |
| 104 | options: InitCollectionOptions<TT, P> = {}, |
| 105 | ): Promise<LoadedCollection<Loaded<TT, P>>> { |
| 106 | if (this.isInitialized(true) && !options.refresh) { |
| 107 | const em = this.getEntityManager(this.#items, false); |
| 108 | options = { ...options, filters: QueryHelper.mergePropertyFilters(this.property.filters, options.filters)! }; |
| 109 | await em?.populate(this.#items, options.populate as any, options as any); |
| 110 | this.setSerializationContext(options); |
| 111 | } else { |
| 112 | await this.init({ refresh: false, ...options }); |
| 113 | } |
| 114 | |
| 115 | return this as unknown as LoadedCollection<Loaded<TT, P>>; |
| 116 | } |
| 117 | |
| 118 | private setSerializationContext<TT extends T>(options: LoadHint<TT, any, any, any>): void { |
| 119 | helper(this.owner).setSerializationContext({ |
no test coverage detected