UNPKG

ravendb

Version:
64 lines 2.55 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.IndexQuery = void 0; exports.writeIndexQuery = writeIndexQuery; const index_js_1 = require("../../Exceptions/index.js"); const IndexQueryWithParameters_js_1 = require("./IndexQueryWithParameters.js"); const HashCalculator_js_1 = require("./HashCalculator.js"); const TypeUtil_js_1 = require("../../Utility/TypeUtil.js"); const Serializer_js_1 = require("../../Mapping/Json/Serializer.js"); class IndexQuery extends IndexQueryWithParameters_js_1.IndexQueryWithParameters { constructor(query) { super(); this.query = query; } /** * Indicates if query results should be read from cache (if cached previously) * or added to cache (if there were no cached items prior) */ disableCaching; getQueryHash(mapper) { const hasher = new HashCalculator_js_1.HashCalculator(); try { hasher.write(this.query, mapper); hasher.write(this.waitForNonStaleResults); hasher.write(this.skipDuplicateChecking); hasher.write(this.skipStatistics); hasher.write(this.waitForNonStaleResultsTimeout || 0); hasher.write(this.queryParameters, mapper); return hasher.getHash(); } catch (err) { (0, index_js_1.throwError)("RavenException", "Unable to calculate hash", err); } } } exports.IndexQuery = IndexQuery; function writeIndexQuery(conventions, indexQuery) { const result = { Query: indexQuery.query }; if (indexQuery.waitForNonStaleResults) { result.WaitForNonStaleResults = indexQuery.waitForNonStaleResults; } if (!TypeUtil_js_1.TypeUtil.isNullOrUndefined(indexQuery.waitForNonStaleResultsTimeout)) { result.WaitForNonStaleResultsTimeout = indexQuery.waitForNonStaleResultsTimeout; } if (indexQuery.disableCaching) { result.DisableCaching = indexQuery.disableCaching; } if (indexQuery.skipDuplicateChecking) { result.SkipDuplicateChecking = indexQuery.skipDuplicateChecking; } if (!indexQuery.queryParameters) { result.QueryParameters = null; } else { result.QueryParameters = indexQuery.queryParameters; } if (indexQuery.projectionBehavior && indexQuery.projectionBehavior !== "Default") { result.ProjectionBehavior = indexQuery.projectionBehavior; } return Serializer_js_1.JsonSerializer.getDefault().serialize(result); } //# sourceMappingURL=IndexQuery.js.map