mantrajs / mantra-sample-blog-app

A sample blog app built with Mantra
http://mantra-sample-blog-app.herokuapp.com/
MIT License
296 stars 104 forks source link

Where do schemas belong? #31

Closed sungwoncho closed 8 years ago

sungwoncho commented 8 years ago

I would like to use aldeed:collection2 to add validations. Where do schemas belong?

If I simply put them in /libs/collections.js, and I have a multitude of collections, I am afraid it would be hard to maintain all schemas.

Edit

just had an idea:

libs
|-- collections
   |-- index.js
   |-- posts.js
   |-- comments.js
   |-- users.js
   ...

libs/collections/index.js

import {Mongo} from 'meteor/mongo';

import Posts from './posts'
import Comments from './comments'
import Users from './users'
...

export default {
  Posts
  Comments
  Users
  ...
}

And define schemas in each /libs/collections/posts.js, /libs/collections/comments.js, ... files.

jrmlstf commented 8 years ago

+1. It's exactly what i did. I like this structure. One file for each collection, it's easy to find all the stuff about a collection.

TimFletcher commented 8 years ago

Yep. This is exactly the same approach I took too.

arunoda commented 8 years ago

This seems like a good approach.