@elizaos/plugin-sql 1.6.2-alpha.2 → 1.6.2-alpha.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.
@@ -20650,9 +20650,12 @@ class BaseDrizzleAdapter extends DatabaseAdapter {
20650
20650
  });
20651
20651
  }
20652
20652
  async getMemories(params) {
20653
- const { entityId, agentId, roomId, worldId, tableName, unique: unique4, start, end } = params;
20653
+ const { entityId, agentId, roomId, worldId, tableName, unique: unique4, start, end, offset } = params;
20654
20654
  if (!tableName)
20655
20655
  throw new Error("tableName is required");
20656
+ if (offset !== undefined && offset < 0) {
20657
+ throw new Error("offset must be a non-negative number");
20658
+ }
20656
20659
  return this.withDatabase(async () => {
20657
20660
  const conditions = [eq(memoryTable.type, tableName)];
20658
20661
  if (start) {
@@ -20676,7 +20679,7 @@ class BaseDrizzleAdapter extends DatabaseAdapter {
20676
20679
  if (agentId) {
20677
20680
  conditions.push(eq(memoryTable.agentId, agentId));
20678
20681
  }
20679
- const query = this.db.select({
20682
+ const baseQuery = this.db.select({
20680
20683
  memory: {
20681
20684
  id: memoryTable.id,
20682
20685
  type: memoryTable.type,
@@ -20690,7 +20693,17 @@ class BaseDrizzleAdapter extends DatabaseAdapter {
20690
20693
  },
20691
20694
  embedding: embeddingTable[this.embeddingDimension]
20692
20695
  }).from(memoryTable).leftJoin(embeddingTable, eq(embeddingTable.memoryId, memoryTable.id)).where(and(...conditions)).orderBy(desc(memoryTable.createdAt));
20693
- const rows = params.count ? await query.limit(params.count) : await query;
20696
+ const rows = await (async () => {
20697
+ if (params.count && offset !== undefined && offset > 0) {
20698
+ return baseQuery.limit(params.count).offset(offset);
20699
+ } else if (params.count) {
20700
+ return baseQuery.limit(params.count);
20701
+ } else if (offset !== undefined && offset > 0) {
20702
+ return baseQuery.offset(offset);
20703
+ } else {
20704
+ return baseQuery;
20705
+ }
20706
+ })();
20694
20707
  return rows.map((row) => ({
20695
20708
  id: row.memory.id,
20696
20709
  type: row.memory.type,
@@ -22202,5 +22215,5 @@ export {
22202
22215
  DatabaseMigrationService
22203
22216
  };
22204
22217
 
22205
- //# debugId=DC208193344AB9F064756E2164756E21
22218
+ //# debugId=314F050492DB8CE564756E2164756E21
22206
22219
  //# sourceMappingURL=index.browser.js.map