UNPKG

firesage

Version:

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

33 lines (32 loc) • 1.19 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.limitToLast = exports.limit = exports.limitCreator = void 0; var firestore_1 = require("firebase/firestore"); var limitCreator = function (type, clause) { return function (limit // impossible route ) { return { type: type, value: limit, ref: clause(limit), }; }; }; exports.limitCreator = limitCreator; /** * Creates a {@link QueryConstraint} that only returns the first matching documents. * * @param limit - The maximum number of items to return. * @returns The created {@link Query}. */ exports.limit = (0, exports.limitCreator)('limit', firestore_1.limit); /** * Creates a {@link QueryConstraint} that only returns the last matching documents. * * You must specify at least one `orderBy` clause for `limitToLast` queries, * otherwise an exception will be thrown during execution.(Prevented on type level) * * @param limit - The maximum number of items to return. * @returns The created {@link Query}. */ exports.limitToLast = (0, exports.limitCreator)('limitToLast', firestore_1.limitToLast);