npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

monetdb-pool

v0.0.8

Published

Module that maintains a connection pool with MonetDB connections.

Downloads

39

Readme

MonetDB Pool NodeJS

Build Status Coverage Status npm version Dependency Status

Node module that maintains a connection pool with MonetDB connections.

Example usage

var MonetDBPool = require("monetdb-pool"); // MonetDBPool now is a constructor

var poolOptions = {
    nrConnections: 8
};

// For all possible database options, see https://github.com/MonetDB/monetdb-nodejs#options
var dbOptions = {
    dbname: "mydb"
};

var pool = new MonetDBPool(poolOptions, dbOptions);

// Execute 1000 queries, which will be divided over all of the connections in the pool
for(var i=0; i<1000; ++i) {
    pool.query("SELECT * FROM yourtable").then(function(result) {
        // Do something with your result here
    }, function(err) {
        // Handle error here
    });
}

// close the pool after finishing all queries.
pool.close();

MonetDBPool object

MonetDBPool(poolOptions, dbOptions)

Constructs a MonetDB connection pool.

| Argument | Type | Required | Description | | :------------------------ | :------------ | :------------- | :-------------- | | poolOptions | object | yes | Object containing options for this pool. | poolOptions.nrConnections | integer | yes | Number of connections to maintain inside this pool. | poolOptions.testing | boolean | no | Only used for testing purposes. If set to true, sets some additional methods on the pool object. Defaults to false. | dbOptions | object | yes | Object containing database options for this pool. See https://github.com/MonetDB/monetdb-nodejs#options for the options you can use here.

MonetDBPool.connect()

Calls the connect method on all initialized MonetDBConnection objects.

Returns a promise that resolves when all connections are successfully connected.

MonetDBPool.query(query, [params], [prettyResult])

Calls MonetDBConnection.query on the next available connection in the pool.

Returns the promise that is returned by MonetDBConnection.query.

MonetDBPool.prepare(query, [prettyResult])

Calls MonetDBConnection.prepare on the next available connection in the pool.

Returns the promise that is returned by MonetDBConnection.prepare.

MonetDBPool.nextConnection([reserve])

Gives you a raw MonetDBConnection object from the connection pool. A non-reserved connection with the least outstanding queries will be returned.

| Argument | Type | Required | Description | | :------------------------ | :------------ | :------------- | :-------------- | | reserve | boolean | no | If set to true, the returned connection will be reserved for usage in your code, meaning this connection will not be used anymore by the connection pool until you call the free() function on it. Note that at the moment you obtain a MonetDBConnection object, it might still be working on other queries so queries that you issue will have to wait in the queue for completion of these earlier queries. If set to false, or omitted, the connection pool will keep on using this connection.

Returns a MonetDBConnection object with the additional method free(), which should be used when you are done with the connection (only if you reserved the connection). When there are no available (unreserved) connections, this method will return null.

Warning: When you query MonetDBConnection objects directly, the connection pool will not know about these queries. This might result in unfair query loads for the connection object you are using. Hence we advice to keep this kind of usage to a minimum.

MonetDBPool.close()

Calls the close method on all initialized MonetDBConnection objects.

Returns a promise that resolves when all connections are successfully closed.