auxilincom / node-mongo

Node Mongo — is reactive 🚀 extension to MongoDB API
MIT License
5 stars 2 forks source link

Migration from monk to mongoose #5

Closed ezhivitsa closed 5 years ago

ezhivitsa commented 5 years ago

@anorsich Please, review

ezhivitsa commented 5 years ago

@anorsich mongoose (and monk) have very interesting capabilities. We can create connection and immediately do requests to the database without waiting to establish the connection. This functionality realized through the special queue which store requests before the connection will be successfully established. Of course, we can write such code but I'm not sure that this is the right way. You can read about this here. Also, I thought about using some package for converting joi to mongoose schema (for example https://gist.github.com/stongo/6359042). But sometimes we need the schema itself for manipulation. for example, the correct way to create indexes in mongoose is using schema (https://mongoosejs.com/docs/guide.html#indexes)

anorsich commented 5 years ago

Well, in memory Q is not difficult to implement. Is it the only magic we want to have? I would use this package for two main reasons:

  1. Separate, clean db objects schema (Joi/Jsonschema)
  2. Reactive events, which make it easy to decouple entities from each other.
  3. Auto-connect is cool feature, but you can always wait for mongodb connection, before launching app. So, we can just skip this feature to make first version clean.