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

Be able to customize Meteor.users schema #44

Closed
mquandalle opened this issue Jan 12, 2014 · 7 comments
Closed

Be able to customize Meteor.users schema #44

mquandalle opened this issue Jan 12, 2014 · 7 comments

Comments

@mquandalle
Copy link
Contributor

Meteor.users is the default meteor collection storing users documents. It would be cool to be able to define extra fields with extra rules such as index or autoValue on this special collection.

Since this collection already have a kind of default schema, maybe we could use an extendSchema method to define new fields?

@aldeed
Copy link
Collaborator

aldeed commented Jan 12, 2014

Good idea. I think both addSchema and extendSchema would be necessary. addSchema could be used to do everything the constructor function does, but after the object is initialized. C2 package could call this by default on Meteor.users to add the base schema. Then package users could call Meteor.users.extendSchema to add their own definitions for metadata fields, etc.

I think it's reasonable to autovalidate Meteor.users when c2 is used, but we'd want to make sure this is a well documented feature.

@wbashir
Copy link

wbashir commented Mar 13, 2014

+1

@petrometro
Copy link
Contributor

Would love to know is someone working on this feature/is it already implemented ? I've noticed that Meteor.users.simpleSchema() exists but is empty by default. Is there a way to dynamically assign a schema to a collection after the collection has been created ? Eg something like

Meteor.users.schema = new SimpleSchema({
'profile' : {
type : ProfileSchema
},
'foo' : {
type : String
}
});

That would be really great if I could set up a schema on Meteor.users so that there would be automatic validations based on my schema whenever I try to insert a new user or to update a user.

@aldeed
Copy link
Collaborator

aldeed commented Mar 22, 2014

Nobody working on it. I plan to when I get time. Best I can say at the moment is probably sometime this month. Will probably be something like Meteor.users.attachSchema(mySimpleSchema).

@petrometro
Copy link
Contributor

This is super useful - great work and thanks so much !

@aldeed
Copy link
Collaborator

aldeed commented Apr 14, 2014

Added documentation for this in the README.

@sabbaticaldev
Copy link

Great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants