@voltagent/libsql 2.0.2 → 2.0.3

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.mjs CHANGED
@@ -590,6 +590,19 @@ var LibSQLMemoryCore = class {
590
590
  });
591
591
  }
592
592
  }
593
+ async deleteMessages(messageIds, userId, conversationId) {
594
+ await this.initialize();
595
+ if (messageIds.length === 0) {
596
+ return;
597
+ }
598
+ const messagesTable = `${this.tablePrefix}_messages`;
599
+ const placeholders = messageIds.map(() => "?").join(",");
600
+ const sql = `DELETE FROM ${messagesTable} WHERE conversation_id = ? AND user_id = ? AND message_id IN (${placeholders})`;
601
+ await this.client.execute({
602
+ sql,
603
+ args: [conversationId, userId, ...messageIds]
604
+ });
605
+ }
593
606
  // ============================================================================
594
607
  // Conversation Operations
595
608
  // ============================================================================
@@ -702,6 +715,23 @@ var LibSQLMemoryCore = class {
702
715
  updatedAt: row.updated_at
703
716
  }));
704
717
  }
718
+ async countConversations(options) {
719
+ await this.initialize();
720
+ const conversationsTable = `${this.tablePrefix}_conversations`;
721
+ let sql = `SELECT COUNT(*) as count FROM ${conversationsTable} WHERE 1=1`;
722
+ const args = [];
723
+ if (options.userId) {
724
+ sql += " AND user_id = ?";
725
+ args.push(options.userId);
726
+ }
727
+ if (options.resourceId) {
728
+ sql += " AND resource_id = ?";
729
+ args.push(options.resourceId);
730
+ }
731
+ const result = await this.client.execute({ sql, args });
732
+ const count = Number(result.rows[0]?.count ?? 0);
733
+ return Number.isNaN(count) ? 0 : count;
734
+ }
705
735
  async updateConversation(id, updates) {
706
736
  await this.initialize();
707
737
  const conversationsTable = `${this.tablePrefix}_conversations`;