UNPKG

firesage

Version:

🔥 Extremely High Precision Typescript Wrapper for Firestore Web, Providing Unparalleled Type Safe and Dev Experience

50 lines (49 loc) • 1.77 kB
"use strict"; var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { if (!ar) ar = Array.prototype.slice.call(from, 0, i); ar[i] = from[i]; } } return to.concat(ar || Array.prototype.slice.call(from)); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.query = void 0; var firestore_1 = require("firebase/firestore"); /** * Creates a new immutable instance of {@link Query} that is extended to also include * additional query constraints. * * @param query - The {@link Query} instance to use as a base for the new constraints. * @param queryConstraints - The list of {@link QueryConstraint}s to apply. * @throws if any of the provided query constraints cannot be combined with the * existing or new constraints. */ var query = function (query) { var queryConstraints = []; for (var _i = 1; _i < arguments.length; _i++) { queryConstraints[_i - 1] = arguments[_i]; } return firestore_1.query.apply(void 0, __spreadArray([ // @ts-expect-error query], queryConstraints.reduce(function (acc, qc) { var type = qc.type; if (type === 'startAt' || type === 'startAfter' || type === 'endAt' || type === 'endBefore') { qc.values.length !== 0 && acc.push( // @ts-expect-error qc.ref); } else { acc.push( // @ts-expect-error qc.ref); } return acc; }, []), false)); }; exports.query = query;