ravendb
Version:
RavenDB client for Node.js
41 lines • 1.15 kB
JavaScript
import { TypeUtil } from "../../../Utility/TypeUtil.js";
/**
* Fluent implementation for specifying include paths
* for loading documents
*/
export class MultiLoaderWithInclude {
_session;
_includes = [];
/**
* Includes the specified path.
*/
include(path) {
this._includes.push(path);
return this;
}
/**
* Loads the specified ids.
*/
async load(ids, documentType) {
let singleResult = false;
if (TypeUtil.isString(ids)) {
ids = [ids];
singleResult = true;
}
const entityType = this._session.conventions.getJsTypeByDocumentType(documentType);
const results = await this._session.loadInternal(ids, {
includes: this._includes,
documentType: entityType
});
return singleResult ?
Object.keys(results).map(x => results[x]).find(x => x) :
results;
}
/**
* Initializes a new instance of the MultiLoaderWithInclude class
*/
constructor(session) {
this._session = session;
}
}
//# sourceMappingURL=MultiLoaderWithInclude.js.map