firelordjs
Version:
🔥 High Precision Typescript Wrapper for Firestore Web, Providing Unparalleled Type Safe and Dev Experience
26 lines (25 loc) • 929 B
JavaScript
import { limit as limit_, limitToLast as limitToLast_, } from 'firebase/firestore';
export var limitCreator = function (type, clause) { return function (limit) {
return {
type: type,
// @ts-expect-error
ref: clause(limit),
};
}; };
/**
* 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}.
*/
export var limit = limitCreator('limit', 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}.
*/
export var limitToLast = limitCreator('limitToLast', limitToLast_);