UNPKG

firelordjs

Version:

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

31 lines (30 loc) • 1.04 kB
import { where as where_ } from 'firebase/firestore'; /** * Creates a QueryConstraint that enforces that documents must contain the * specified field and that the value should satisfy the relation constraint * provided. * * @param fieldPath - The path to compare * @param opStr - The operation string (e.g "<", "<=", "==", "<", * "<=", "!="). * @param value - The value for comparison * @returns The created Query. */ export var where = function (fieldPath, opStr, value) { var newValue = value; if (Array.isArray(newValue) && (opStr === 'in' || opStr === 'array-contains-any' || opStr === 'not-in') && newValue.length === 0) { newValue = [ '712zy78yn73x8y037zym83y1x82y3n8cy38u89zul,98kup3c289 2unp38yn8nyz83ym073`yzmo7cyun8z90 ,u2e8 ' + Date.now().toLocaleString(), ]; } return { type: 'where', fieldPath: fieldPath, opStr: opStr, value: value, ref: where_(fieldPath, opStr, newValue), }; };