Save huge document (record) using Mongoose and Node.js
Budget: $50 – $60 CAD
Hi,
I am working with mongoose and node.js. I want to insert a new huge "Record" using this lines :
const RawRecord = {
user_id : user._id.toString(),
user_email : record.user.email,
hexoskin_record_id : req.body.record_id,
hexoskin_start_date : record.start_date.toString(),
hexoskin_duration : record.duration,
status : record.status,
acceleration_x : Object.values( acceleration_X),
acceleration_y : Object.values( acceleration_Y),
acceleration_z : Object.values( acceleration_Z),
respiration_thoracic : Object.values( respiration_thoracic),
respiration_abdominal : Object.values( respiration_abdominal)
};
const rawrecord = new RawRecords(RawRecord);
const NewRawRecord = await rawrecord.save(); //<== error at this line, because the data are too big. and I receive this message:
RangeError: Value undefined out of range for undefined options property undefined
"RawRecord" variable : See the attached file
To solve this problem :
- Split this into many individual doc with ref to mother entity
- Then we can use mongodb aggregate pipeline to group them again when we need to access them
- Use $match and $lookup
Regards
I am working with mongoose and node.js. I want to insert a new huge "Record" using this lines :
const RawRecord = {
user_id : user._id.toString(),
user_email : record.user.email,
hexoskin_record_id : req.body.record_id,
hexoskin_start_date : record.start_date.toString(),
hexoskin_duration : record.duration,
status : record.status,
acceleration_x : Object.values( acceleration_X),
acceleration_y : Object.values( acceleration_Y),
acceleration_z : Object.values( acceleration_Z),
respiration_thoracic : Object.values( respiration_thoracic),
respiration_abdominal : Object.values( respiration_abdominal)
};
const rawrecord = new RawRecords(RawRecord);
const NewRawRecord = await rawrecord.save(); //<== error at this line, because the data are too big. and I receive this message:
RangeError: Value undefined out of range for undefined options property undefined
"RawRecord" variable : See the attached file
To solve this problem :
- Split this into many individual doc with ref to mother entity
- Then we can use mongodb aggregate pipeline to group them again when we need to access them
- Use $match and $lookup
Regards