Skip to content

Commit

Permalink
Merge pull request #64 from JoinTheAlliance/sqlite-fixes
Browse files Browse the repository at this point in the history
Sqlite adapter fixes: Handle unique and order for memories
  • Loading branch information
lalalune authored Mar 21, 2024
2 parents 5e57e16 + 877e5fb commit 30db76c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bgent",
"version": "0.1.4",
"version": "0.1.5",
"private": false,
"description": "bgent. because agent was taken.",
"type": "module",
Expand Down
9 changes: 6 additions & 3 deletions src/lib/adapters/sqlite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,12 @@ AND room_id = ?`;

const queryParams = [params.tableName, params.room_id];

// if (params.unique) {
// sql += " AND `unique` = 1";
// }
if (params.unique) {
sql += " AND `unique` = 1";
}

// get the most recent memories
sql += " ORDER BY created_at DESC";

if (params.count) {
sql += " LIMIT ?";
Expand Down
6 changes: 6 additions & 0 deletions src/lib/adapters/sqljs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,12 @@ export class SqlJsDatabaseAdapter extends DatabaseAdapter {
}
let sql = `SELECT * FROM memories WHERE type = ? AND room_id = ?`;

if (params.unique) {
sql += " AND `unique` = 1";
}

sql += " ORDER BY created_at DESC";

if (params.count) {
sql += " LIMIT ?";
}
Expand Down

0 comments on commit 30db76c

Please sign in to comment.