You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched existing issues to ensure the bug has not already been reported
Mongoose version
8.x.x
Node.js version
22.x
MongoDB server version
5.x
Typescript version (if applicable)
No response
Description
Mongoose 8 seems to have an issue with type: Buffer field. It will set a buffer, but not return one. Will only work if the type is Any.
Mongoose will save type:Buffer as normal, but when retrieving the same document it will not return the type: Buffer. If you instead set field to type: Any, then it returns fine. Mongoose 6 worked as intended, however in Mongoose 7+ it seems to have stopped returning a buffer field.
In v8 when field is type: Buffer, saves as Binary.createFromBase64('xxx...), but will not return the field when retrieving the document.
When changing the field schema to type: Any, it "works" but saves as an object {"type":"buffer", "data": [...]}
Steps to Reproduce
Create a document with a schema field of type: Buffer.
Update the document field with a buffer.
Retrieve the document and the field will be undefined.
Instead of type: Buffer, use type: Any, or just {};
Update the document field with a buffer.
Retrieve the document and the field is returned as an object.
Expected Behavior
Should work as in Mongoose 6, saves type: Buffer and will retrieve it as well.
The text was updated successfully, but these errors were encountered:
Prerequisites
Mongoose version
8.x.x
Node.js version
22.x
MongoDB server version
5.x
Typescript version (if applicable)
No response
Description
Mongoose 8 seems to have an issue with type: Buffer field. It will set a buffer, but not return one. Will only work if the type is Any.
Mongoose will save type:Buffer as normal, but when retrieving the same document it will not return the type: Buffer. If you instead set field to type: Any, then it returns fine. Mongoose 6 worked as intended, however in Mongoose 7+ it seems to have stopped returning a buffer field.
In v8 when field is type: Buffer, saves as Binary.createFromBase64('xxx...), but will not return the field when retrieving the document.
When changing the field schema to type: Any, it "works" but saves as an object {"type":"buffer", "data": [...]}
Steps to Reproduce
Create a document with a schema field of type: Buffer.
Update the document field with a buffer.
Retrieve the document and the field will be undefined.
Instead of type: Buffer, use type: Any, or just {};
Update the document field with a buffer.
Retrieve the document and the field is returned as an object.
Expected Behavior
Should work as in Mongoose 6, saves type: Buffer and will retrieve it as well.
The text was updated successfully, but these errors were encountered: