Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const ODatabase = require('orientjs').ODatabase;
- const genericPool = require('generic-pool');
- const factory = {
- create: function(){
- const db = new ODatabase({
- host: 'localhost',
- port: 2424,
- username: 'admin',
- password: 'admin',
- name: 'GratefulDeadConcerts'
- });
- return db.open();
- },
- destroy: function(client){
- return client.close();
- }
- }
- const opts = {
- max: 10, // maximum size of the pool
- min: 2 // minimum size of the pool
- }
- let pool = genericPool.createPool(factory, opts)
- pool.acquire()
- .then(function(db){
- db.query('select from v limit 1')
- .then(function(res){
- console.log(res);
- return pool.release(db);
- })
- .then(function(){
- return pool.drain();
- })
- .then(function(){
- return pool.clear();
- })
- })
Add Comment
Please, Sign In to add comment