Can someone explain how MongoDB's persistent connections work? -
i'm used writing little scale web applications, , [at work] we're building our customers anticipate pretty data-intensive.
we've chosen mongodb because of loose schema scheme need i'm little confused how mongodb handles connections. way taught open connection, perform crud operation, close connection. mongodb docs should never need utilize close connection function in normal circumstances. need creating these mongo client objects , stuff?
what best practices utilize here? first time using database engine isn't relational.
that vary based on driver (the client library, different every language).
in c# driver @ least, don't need create more single client, , utilize throughout application. don't need create connection, it's internal , managed you.
take illustration extremely simple code. creates client, gets database, gets collection within , retrieves documents in collection (and if 1 of them doesn't exist, create them):
var client = new mongoclient(); var hamsters = client.getserver().getdatabase("hamsterschool").getcollection("hamsters").findall();
mongodb persistent-connection
No comments:
Post a Comment