firelordjs
Version:
🔥 High Precision Typescript Wrapper for Firestore Web, Providing Unparalleled Type Safe and Dev Experience
65 lines (64 loc) • 3 kB
JavaScript
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
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));
};
import { docCreator, collectionCreator, collectionGroupCreator, andCreator, orCreator, } from './refs';
import { Timestamp } from 'firebase/firestore';
export var getFirelordShakable = function (_a) {
var docCreator = _a.docCreator, collectionCreator = _a.collectionCreator, collectionGroupCreator = _a.collectionGroupCreator, andCreator = _a.andCreator, orCreator = _a.orCreator;
// @ts-expect-error
return function (firestore) {
var collectionIDs = [];
for (var _i = 1; _i < arguments.length; _i++) {
collectionIDs[_i - 1] = arguments[_i];
}
return __assign(__assign(__assign(__assign(__assign({}, (docCreator && {
doc: docCreator.apply(void 0, __spreadArray([firestore], collectionIDs, false)),
})), (collectionCreator && {
collection: collectionCreator.apply(void 0, __spreadArray([firestore], collectionIDs, false)),
})), (collectionGroupCreator && {
collectionGroup: collectionGroupCreator(firestore, collectionIDs[collectionIDs.length - 1]),
})), (orCreator && { or: orCreator() })), (andCreator && { and: andCreator() }));
};
};
/**
* Gets a FirelordReference instance that refers to the doc, collection, and collectionGroup at the specified absolute path.
* @param firestore - A reference to the root `Firestore` instance.
* @param collectionIDs - all the collectionID(s) needed to build this collection path.
* @returns function of DocumentReference, CollectionReference, CollectionGroup and composite queries.
*/
export var getFirelord = getFirelordShakable({
docCreator: docCreator,
collectionCreator: collectionCreator,
collectionGroupCreator: collectionGroupCreator,
andCreator: andCreator,
orCreator: orCreator,
});
export var toTimestamp = function (_a) {
var seconds = _a.seconds, nanoseconds = _a.nanoseconds;
return new Timestamp(seconds, nanoseconds);
};
export { getFirestore, Timestamp, GeoPoint, Bytes, connectFirestoreEmulator, } from 'firebase/firestore';
export * from './batch';
export * from './transaction';
export * from './fieldValues';
export * from './operations';
export * from './queryConstraints';
export * from './refs';
export * from './equal';