@tanstack/db
Version:
A reactive client store for building super fast apps on sync
58 lines (57 loc) • 1.5 kB
JavaScript
;
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const utils = require("../../utils.cjs");
function queriesMatchForCaching(a, b) {
return utils.deepEquals(normalizeQuery(a), normalizeQuery(b));
}
function normalizeQuery(query) {
return {
from: normalizeFrom(query.from),
select: query.select,
join: query.join?.map((join) => ({
from: normalizeFrom(join.from),
type: join.type,
left: join.left,
right: join.right
})),
where: query.where,
groupBy: query.groupBy,
having: query.having,
orderBy: query.orderBy,
limit: query.limit,
offset: query.offset,
distinct: query.distinct,
singleResult: query.singleResult,
fnSelect: query.fnSelect,
fnWhere: query.fnWhere,
fnHaving: query.fnHaving
};
}
function normalizeFrom(from) {
switch (from.type) {
case `collectionRef`:
return {
type: from.type,
collection: from.collection,
alias: from.alias
};
case `queryRef`:
return {
type: from.type,
query: normalizeQuery(from.query),
alias: from.alias
};
case `unionFrom`:
return {
type: from.type,
sources: from.sources.map(normalizeFrom)
};
case `unionAll`:
return {
type: from.type,
queries: from.queries.map(normalizeQuery)
};
}
}
exports.queriesMatchForCaching = queriesMatchForCaching;
//# sourceMappingURL=query-equivalence.cjs.map