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

Collection Question #37

Closed
rjsandman opened this issue Dec 15, 2013 · 1 comment
Closed

Collection Question #37

rjsandman opened this issue Dec 15, 2013 · 1 comment

Comments

@rjsandman
Copy link

Hello,

I think I am missing something. Where do you create your collection and how do you tie it to the schema? (without using collection2)

Thanks

@aldeed
Copy link
Collaborator

aldeed commented Dec 17, 2013

This package on it's own is meant to be very generic, so that it can be used to enforce schema for any javascript object, not necessarily related to a collection at all.

If you want to tie the schema to a collection, you'll have to write a bunch of code that would end up being the same as the code in the collection2 package, so you should just use collection2. Otherwise, the simplest way to use it without collection2 would be to:

  1. Use deny functions to deny all inserts and updates from the client.
  2. Create server methods that you can call from the client to do inserts, etc. Pass your insert doc or update modifier to these methods.
  3. In the insert server method, call check(doc, mySimpleSchema) to make sure the doc to be inserted matches the schema. Then perform the insert on the server.
  4. In the update server method, call check(modifier, mySimpleSchema) to make sure the modifier for the update matches the schema. Then perform the update on the server.

@aldeed aldeed closed this as completed Dec 26, 2013
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