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
Thanks for writing this great plugin. I'm using it in several collections.
I'm also trying to use mongoose-types in a embedded document, but it does not work: The first sub-document is added without any problems but then I cannot add more sub-documents. I always get the following error:
http.js:543
throw new Error("Can't use mutable header APIs after sent.");
Here is the code:
//add tracker to account.
var Actor = mongoose.model('Actor');
function add_tracker(req, res, next) {
Actor.findById(req.params.id, function(err, actor) {
if (err) {
console.log(err);
}
var tracker_value = req.body.tracker.value;
var tracker = { value: tracker_value };
var trackers_size = actor.trackers.length;
actor.trackers.push(tracker);
actor.save(function(err){
res.local("actor", actor);
if (err) res.send({ error: err.message });
var tracker = actor.trackers[trackers_size];
res.partial('account/_tracker', { object: tracker }, function(err, html) {
if (err) {
res.send({ error: err.message });
} else {
res.send({ prepend: html, to: '#tracker_list' });
}
});
})
});
}
//database schema:
var mongoose = require('mongoose'),
mongooseTypes = require("mongoose-types"),
useTimestamps = mongooseTypes.useTimestamps;
var Trackers = new Schema({
value : String
});
Trackers.plugin(useTimestamps);
var Actor = new Schema({
, name : String
, trackers : [Trackers]
});
mongoose.model('Actor', Actor);
If I remove mongoose-types from the embedded the error does not occur.
Thanks.
Best regards,
Migrate
The text was updated successfully, but these errors were encountered:
Hi,
Thanks for writing this great plugin. I'm using it in several collections.
I'm also trying to use mongoose-types in a embedded document, but it does not work: The first sub-document is added without any problems but then I cannot add more sub-documents. I always get the following error:
http.js:543
throw new Error("Can't use mutable header APIs after sent.");
Here is the code:
If I remove mongoose-types from the embedded the error does not occur.
Thanks.
Best regards,
Migrate
The text was updated successfully, but these errors were encountered: