Mongodb automatically create schema collections

1,587 views
Skip to first unread message

Yulias Stolin

unread,
Apr 30, 2012, 4:32:08 PM4/30/12
to mongodb-user
Hi
I know that mongo creates things on the fly. But I would like to have
some script for creating schema (db) collections, and each time that
new schema (db) is created (on the fly) mongo will automatically
execute this script. So my code will be unaware of indexes and sharing
configuration. Can I do such thing, and how?

Adam C

unread,
May 1, 2012, 7:47:50 AM5/1/12
to mongod...@googlegroups.com
Not 100% sure what you mean by creating things on the fly, but it sounds like you want triggers on the server.  There is a request tracking this that you can watch and vote for:


But, it does not exist yet and is not scheduled for implementation.  At the moment, therefore, you need to do this type of thing client side.


But again, you're a little vague about what you are trying to accomplish.

Adam

Yulias Stolin

unread,
May 1, 2012, 4:20:20 PM5/1/12
to mongodb-user
I have an application with multiple accounts. In each account i have
the same tables.
The account could be created dynamically (this is rare event no
special business logic on that)
But in other hand i didn't want to treat at the code the new account
creation, and then ensure an index for the collections, and configure
their shard definition
So I wanted something automatic in mongo. Probably it is not possible

Scott Hernandez

unread,
May 1, 2012, 5:28:00 PM5/1/12
to mongod...@googlegroups.com
This is best put in your business logic/code when new accounts are created.

Wherever the code is that uses the database for the first time could
also set everything up correctly before.
> --
> You received this message because you are subscribed to the Google Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com.
> To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
>
Reply all
Reply to author
Forward
0 new messages