Skip to content

Commit

Permalink
mongodb[patch]: Fix bug in mongodb storage.ts (#6361)
Browse files Browse the repository at this point in the history
* Fix bug mongodb storage.ts

When retrieving records the value was always JSON.stringified even if the value was already in JSON.  As a result, MongoStore could not be used with standard retrievers like the ParentRetriever as it would always return documents with undefined for pageContent.

* Update storage.ts

---------

Co-authored-by: Jacob Lee <[email protected]>
  • Loading branch information
drewB and jacoblee93 authored Aug 3, 2024
1 parent c8b2ffb commit 34df3f3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion libs/langchain-mongodb/src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,10 @@ export class MongoDBStore extends BaseStore<string, Uint8Array> {
}
if (value === undefined || value === null) {
return undefined;
} else if (typeof value === "object") {
} else if (typeof value.value === "object") {
return encoder.encode(JSON.stringify(value.value));
} else if (typeof value.value === "string") {
return encoder.encode(value.value);
} else {
throw new Error("Unexpected value type");
}
Expand Down

0 comments on commit 34df3f3

Please sign in to comment.