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

Best way to add mongodb? #525

Closed
vadimsg opened this issue Nov 23, 2017 · 11 comments
Closed

Best way to add mongodb? #525

vadimsg opened this issue Nov 23, 2017 · 11 comments
Labels

Comments

@vadimsg
Copy link

vadimsg commented Nov 23, 2017

Hello there,

What would be the best way to add mongodb to this starter-kit? SQL will not do for my project.
Was looking in issues and was surprised no one was asking before it.

Thanks for any information!

@larixer
Copy link
Member

larixer commented Nov 23, 2017

@vadimsg The kit is database-agnostic. It is examples of server-side modules, e.g. src/server/modules that use particular database. So add your own server module and use MongoDB, or graph database (this is what several people do), or anything else. Maybe start with porting counter example to MongoDB

@vadimsg
Copy link
Author

vadimsg commented Nov 23, 2017

@Vlasenko Thanks for the reply! By the way maybe some one has a mini example for mongo server module or directions what is needed to be done, what to connect to include other db support so this kit works with it as good as with out of the box supported db. Looking at those different settings/configs for mysql, pg, sqlite that somehow work together with this kit and different libraries are not helping much at the moment as I'm new in so advanced scenarios and for each db are different approaches/settings how to use it with this kit.

Would appreciate any sort of small list about what/where to connect, what to not forget etc.
Thanks!

@MichelDiz
Copy link

When I do some testing of another database in this Kit. I usually create a generic connector inside the folder "/src/server/sql/myCustomConnector.js". After that I only add in the module sql.js the path of this connector and make my calls normally. You do not even need to take the Knex out of the kit.

You can use "/src/server/modules/myModule/sql.js" or modify the sql.js name to "mongodb.js" just for the sake of aesthetics.

@vadimsg
Copy link
Author

vadimsg commented Nov 24, 2017

@MichelDiz Thanks a lot!
Other tips, best practises for this module are welcome.

@mitjade
Copy link
Collaborator

mitjade commented Nov 28, 2017

@vadimsg Ware you able to make the MongoDB connection work with this kit?

@vadimsg
Copy link
Author

vadimsg commented Nov 28, 2017

@mitjade yes, thank you guys for tips. Great kit!

@mitjade
Copy link
Collaborator

mitjade commented Nov 28, 2017

@vadimsg Great! Would you be willing to make a PR or your solution?
It does not need to be perfect, we can help out in making it acceptable to be merged in the kit or we can even just leave it in a PR, so someone else having the same problem would find this helpful.

@vadimsg
Copy link
Author

vadimsg commented Nov 28, 2017

@mitjade Ok, I will try to make it when will have free time.

@mitjade
Copy link
Collaborator

mitjade commented Nov 28, 2017

@vadimsg Great! Thank you in advance.

@larixer larixer closed this as completed Dec 5, 2017
@email2vimalraj
Copy link

@vadimsg : Could you please post some example on how did you achieve on integrating with mongo?

@kfrajtak
Copy link

I had a look at the code (I want to integrate with Mongo as well) and the best place is probably here https://github.com/sysgears/apollo-universal-starter-kit/blob/master/src/server/modules/user/resolvers.js#L12

users: withAuth(['user:view:all'], (obj, { orderBy, filter }, context) => {
  return context.User.getUsers(orderBy, filter); // <---- here you can call Mongo
}),

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

No branches or pull requests

6 participants