Okay so. What I am trying to create is the ability to select multiple templates, fork them, and merge them into one entity on another collection. Let’s just say it’s for forking gists as an example
/** example template collection */
var JSTemplate = {
_id: "someid",
title: "Getting started with JavaScript",
languageId: "someId",
author: "someotherid",
defaults: {
colorScheme: "night",
syntaxHighlighter: "pygments"
}
}
// creating a fork
var user = {
_id: "anotherid",
name: "Corvid",
forks: [{
forkedFrom: "someid",
originalTitle: "Getting started with javascript",
originalAuthorName: "Boudicca",
content: "..."
}, {
forkedFrom: "someid",
originalTitle: "ayy lmao",
originalAuthorName: "Boudicca",
content: "..."
]]
}
So I have a simple schema like this:
var UserSchema = new SimpleSchema({
name: { type: String },
forks: { type: [Object] },
"forks.$.forkedFrom": { type: String },
"forks.$.originalTitle": { type: Date },
"forks.$.originalAuthorName": { type: String },
"forks.$.content": { type: String }
});
Then my Meteor.method
to create it grabs a form on submit and creates the multiforks.
Meteor.methods({
multifork: function(template) {
var authorId = template.authorId;
var newRepo = Repos.find({
_id: { $in: template.repos }
}).map(function(doc) {
return {
forkedFrom: doc._id,
originalTitle: doc.title,
authorName: doc.author().name,
content: doc.code.content
}
});
var codeId = UserCode.insert({
authorId: authorId,
code: newRepo
});
Meteor.users.update(authorId, {
$addToSet: { forks: codeId }
});
}
});
So I can submit the form, and it creates it, and I can query in meteor mongo
and find the entry exactly as I expected.
However, when I try to go to an update form, I keep getting this on the client console:
Exception from Tracker recompute function: undefined
Error: Meteor does not currently support objects other than ObjectID as ids
I can still manage to render every field except forks
with autoform. Has anyone run into this?