Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Big request: Schema join (including AutoForm) #309

Closed
AlexFrazer opened this issue Mar 23, 2015 · 1 comment
Closed

Big request: Schema join (including AutoForm) #309

AlexFrazer opened this issue Mar 23, 2015 · 1 comment

Comments

@AlexFrazer
Copy link

Let's say I have a simple database where there are Students and Classes. It would be very ideal if there was some kind of join where you could create a Schema that relates to other Schemas. For example,

StudentSchema = new SimpleSchema({
  name: { type: String },
  classes: [Schema({
    relationship: "Classes",
    max: 5,
    min: 1
  })]
});

So if you do Student.findOne(), it could look like this:

{
  name: "Steve",
  classes: [{
    name: "Calculus",
    department: "Math"
  }, {
    name: "Painting",
    department: "Art"
  }]
}

Would this be possible?

EDIT: I know you can kind of do it this way. Maybe it'd be nice to expedite the process.

classes: {
  type: [String],
  autoform: {
    options: function() {
      return Classes.find().map(function(doc) {
        return { label: doc.name, value: doc._id};
      })
    }
  }
}
@aldeed
Copy link
Collaborator

aldeed commented Mar 26, 2015

This may be done someday in collection2, tracked here, and then autoform could also take advantage of these relationships as you describe.

@aldeed aldeed closed this as completed Mar 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants