@onyx.dev/onyx-database 1.0.3 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1325,6 +1325,14 @@ var OnyxDatabaseImpl = class {
1325
1325
  qb.select(...fields);
1326
1326
  return qb;
1327
1327
  }
1328
+ search(queryText, minScore) {
1329
+ const qb = new QueryBuilderImpl(
1330
+ this,
1331
+ "ALL",
1332
+ this.defaultPartition
1333
+ );
1334
+ return qb.search(queryText, minScore);
1335
+ }
1328
1336
  cascade(...relationships) {
1329
1337
  const cb = new CascadeBuilderImpl(this);
1330
1338
  return cb.cascade(...relationships);
@@ -1611,6 +1619,7 @@ var QueryBuilderImpl = class {
1611
1619
  toSelectQuery() {
1612
1620
  return {
1613
1621
  type: "SelectQuery",
1622
+ table: this.table,
1614
1623
  fields: this.fields,
1615
1624
  conditions: this.serializableConditions(),
1616
1625
  sort: this.sort,
@@ -1650,6 +1659,13 @@ var QueryBuilderImpl = class {
1650
1659
  this.resolvers = flat.length > 0 ? flat : null;
1651
1660
  return this;
1652
1661
  }
1662
+ search(queryText, minScore) {
1663
+ return this.and({
1664
+ field: "__full_text__",
1665
+ operator: "MATCHES",
1666
+ value: { queryText, minScore: minScore ?? null }
1667
+ });
1668
+ }
1653
1669
  where(condition) {
1654
1670
  const c2 = toCondition(condition);
1655
1671
  if (!this.conditions) {
@@ -2001,6 +2017,10 @@ var ConditionBuilderImpl = class {
2001
2017
 
2002
2018
  // src/helpers/conditions.ts
2003
2019
  var c = (field, operator, value) => new ConditionBuilderImpl({ field, operator, value });
2020
+ var fullText = (queryText, minScore) => ({
2021
+ queryText,
2022
+ minScore: minScore ?? null
2023
+ });
2004
2024
  var eq = (field, value) => c(field, "EQUAL", value);
2005
2025
  var neq = (field, value) => c(field, "NOT_EQUAL", value);
2006
2026
  function inOp(field, values) {
@@ -2023,6 +2043,7 @@ var gte = (field, value) => c(field, "GREATER_THAN_EQUAL", value);
2023
2043
  var lt = (field, value) => c(field, "LESS_THAN", value);
2024
2044
  var lte = (field, value) => c(field, "LESS_THAN_EQUAL", value);
2025
2045
  var matches = (field, regex) => c(field, "MATCHES", regex);
2046
+ var search = (queryText, minScore) => c("__full_text__", "MATCHES", fullText(queryText, minScore));
2026
2047
  var notMatches = (field, regex) => c(field, "NOT_MATCHES", regex);
2027
2048
  var like = (field, pattern) => c(field, "LIKE", pattern);
2028
2049
  var notLike = (field, pattern) => c(field, "NOT_LIKE", pattern);
@@ -2089,6 +2110,7 @@ exports.percentile = percentile;
2089
2110
  exports.replace = replace;
2090
2111
  exports.sdkName = sdkName;
2091
2112
  exports.sdkVersion = sdkVersion;
2113
+ exports.search = search;
2092
2114
  exports.startsWith = startsWith;
2093
2115
  exports.std = std;
2094
2116
  exports.substring = substring;