@elizaos/plugin-sql 1.2.11-beta.9 → 1.3.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 +8 -5
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1609,14 +1609,15 @@ var BaseDrizzleAdapter = class extends DatabaseAdapter {
|
|
|
1609
1609
|
});
|
|
1610
1610
|
isUnique = similarMemories.length === 0;
|
|
1611
1611
|
}
|
|
1612
|
-
const contentToInsert = typeof memory.content === "string" ?
|
|
1612
|
+
const contentToInsert = typeof memory.content === "string" ? memory.content : JSON.stringify(memory.content ?? {});
|
|
1613
|
+
const metadataToInsert = typeof memory.metadata === "string" ? memory.metadata : JSON.stringify(memory.metadata ?? {});
|
|
1613
1614
|
await this.db.transaction(async (tx) => {
|
|
1614
1615
|
await tx.insert(memoryTable).values([
|
|
1615
1616
|
{
|
|
1616
1617
|
id: memoryId,
|
|
1617
1618
|
type: tableName,
|
|
1618
1619
|
content: sql16`${contentToInsert}::jsonb`,
|
|
1619
|
-
metadata: sql16`${
|
|
1620
|
+
metadata: sql16`${metadataToInsert}::jsonb`,
|
|
1620
1621
|
entityId: memory.entityId,
|
|
1621
1622
|
roomId: memory.roomId,
|
|
1622
1623
|
worldId: memory.worldId,
|
|
@@ -1655,14 +1656,16 @@ var BaseDrizzleAdapter = class extends DatabaseAdapter {
|
|
|
1655
1656
|
});
|
|
1656
1657
|
await this.db.transaction(async (tx) => {
|
|
1657
1658
|
if (memory.content) {
|
|
1658
|
-
const contentToUpdate = typeof memory.content === "string" ?
|
|
1659
|
+
const contentToUpdate = typeof memory.content === "string" ? memory.content : JSON.stringify(memory.content ?? {});
|
|
1660
|
+
const metadataToUpdate = typeof memory.metadata === "string" ? memory.metadata : JSON.stringify(memory.metadata ?? {});
|
|
1659
1661
|
await tx.update(memoryTable).set({
|
|
1660
1662
|
content: sql16`${contentToUpdate}::jsonb`,
|
|
1661
|
-
...memory.metadata && { metadata: sql16`${
|
|
1663
|
+
...memory.metadata && { metadata: sql16`${metadataToUpdate}::jsonb` }
|
|
1662
1664
|
}).where(eq(memoryTable.id, memory.id));
|
|
1663
1665
|
} else if (memory.metadata) {
|
|
1666
|
+
const metadataToUpdate = typeof memory.metadata === "string" ? memory.metadata : JSON.stringify(memory.metadata ?? {});
|
|
1664
1667
|
await tx.update(memoryTable).set({
|
|
1665
|
-
metadata: sql16`${
|
|
1668
|
+
metadata: sql16`${metadataToUpdate}::jsonb`
|
|
1666
1669
|
}).where(eq(memoryTable.id, memory.id));
|
|
1667
1670
|
}
|
|
1668
1671
|
if (memory.embedding && Array.isArray(memory.embedding)) {
|