@mastra/libsql 1.21.1 → 1.22.0-alpha.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.js CHANGED
@@ -13054,7 +13054,7 @@ var WorkflowsLibSQL = class WorkflowsLibSQL extends WorkflowsStorage {
13054
13054
  sql: `INSERT INTO ${TABLE_WORKFLOW_SNAPSHOT} (workflow_name, run_id, resourceId, snapshot, createdAt, updatedAt)
13055
13055
  VALUES (?, ?, ?, jsonb(?), ?, ?)
13056
13056
  ON CONFLICT(workflow_name, run_id)
13057
- DO UPDATE SET resourceId = excluded.resourceId, snapshot = excluded.snapshot, updatedAt = excluded.updatedAt`,
13057
+ DO UPDATE SET resourceId = COALESCE(excluded.resourceId, ${TABLE_WORKFLOW_SNAPSHOT}.resourceId), snapshot = excluded.snapshot, updatedAt = excluded.updatedAt`,
13058
13058
  args: [
13059
13059
  workflowName,
13060
13060
  runId,
@@ -13854,6 +13854,15 @@ var LibSQLFactoryStorageOps = class {
13854
13854
  async findMany(collection, where, opts) {
13855
13855
  return this.#select(collection, where, opts);
13856
13856
  }
13857
+ async count(collection, where) {
13858
+ const schema = this.#schema(collection);
13859
+ const filter = this.#buildWhere(schema, where);
13860
+ const result = await this.#client.execute({
13861
+ sql: `SELECT COUNT(*) AS count FROM "${schema.name}" WHERE ${filter.sql}`,
13862
+ args: filter.args
13863
+ });
13864
+ return Number(result.rows[0]?.count ?? 0);
13865
+ }
13857
13866
  async #insertOne(collection, row) {
13858
13867
  const schema = this.#schema(collection);
13859
13868
  const pk = primaryKeyOf(schema);