merge() is not a function
dunklesToast opened this issue · 1 comments
dunklesToast commented
Bug report
When I want to merge an document, it will throw an error :/
My Code:
user.save((err, doc) => {
if(err) throw err;
fs.readFile('./filter.png', (err, data) => {
const dataToAdd = {
profilePicture: data
};
doc.merge(dataToAdd).then((result) => {
console.log(result)
})
})
});
Error Message
/Users/tom/WebstormProjects/<ProjectName>/test.js:28
doc.merge(dataToAdd).then((result) => {
^
TypeError: doc.merge(...).then is not a function
at fs.readFile (/Users/tom/WebstormProjects/<ProjectName>/test.js:28:30)
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:503:3)
Question
Am I doing something wrong?
The Usermodel is defined in another JS Document which is required. Thinky or RethinkDBDash arent required in the file where I want to merge.
Well, this is just a simplified version of what I want to do - I know it makes no sense to merge directly after creation. But in my "real" case I want to merge after I created the user, but the way I want to do it is mostly the same
dunklesToast commented
I found my mistake.
It needs to be
user.merge().save().then((result) => {})
I missed that save()