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

poseidon-mongo

v0.5.0

Published

A future wrapper around the Node Native MongoDB driver using Poseidon.

Downloads

13

Readme

Poseidon Mongo

Poseidon Mongo provides a promise layer around the Node Native MongoDB driver with the help of the Poseidon library.

It has performance on par with the plain mongodb native library

Native MongoDB x 277 ops/sec ±2.42% (80 runs sampled)
Poseidon MongoDB x 271 ops/sec ±2.65% (71 runs sampled)
Fastest is Native MongoDB,Poseidon MongoDB

Install

To get started simply run

npm install poseidon-mongo

Introduction

Compare the example below to the original introduction for the Node MongoDB Native Driver.

Javascript

Mongo = require('../index.js');
Driver = new Mongo.Driver();
Database = Mongo.Database;
assert = require('assert');
Driver.configure('test', { hosts: ['127.0.0.1:27017'], database: 'test', options: { w: 1 } });

client = new Database(Driver, 'test');
client.collection('test_insert')
.then(function(collection){
  return collection.insert({a:2})
  .then(function(docs){
    return collection.count();
  }).then(function(count){
    assert(count, 1);
    return collection.find();
  }).then(function(cursor){
    return cursor.toArray();
  }).then(function(results){
    assert(results.length, 1);
    assert(results[0].a, 2);
  })
}).finally(function(){
  client.close();
}).done();

Coffeescript

It get even better with Jeremy Ashkenas' Coffescript.

Mongo = require '../index'
Driver = new Mongo.Driver()
{Database} = Mongo
assert = require 'assert'

Driver.configure('test', { hosts: ['127.0.0.1:27017'], database: 'test', options: { w: 1 } })

client = new Database(Driver, 'test')
client.collection('test_insert')
.then (collection) ->
  collection.insert({a:2})
  .then (docs) ->
    collection.count()
  .then (count) ->
    assert(count, 1);
    collection.find()
  .then (cursor) ->
    cursor.toArray();
  .then (results) ->
    assert(results.length, 1);
    assert(results[0].a, 2);
.finally () ->
  client.close()
.done()

API

The API for poseidon Mongo contains the complete API for the Node MongoDB Native driver's Db, Collection and Cursor classes.

Driver

The driver class provides for a easy management and configuration of databases through your entire application.

Driver.configure(connection, configuration)

Configures a connection using the given configuration. The possible configuration parameters are given below:

| Parameter | Description | | :-----------: |-------------------------------------------------------------------------------------------------------------------------------------------------------| | auth | An authorization string of the format <user>:<pass>. Eg: 'foo:bar' | | database | The database name | | hosts | An array of hosts to which you wish to connect | | options | Any additional options. Find the full list of options here |

Driver.openConnection(connection)

Open a previously configured connection and cache it for future reuse.

Driver.closeConnection(connection)

Close a connection and remove it from the cache.

Driver.reset()

Close all open connections and delete all configurations.

Database

The following functions are available. For detailed interface information check the Node MongoDB Native Documentation

  • addUser
  • authenticate
  • close
  • collection
  • collectionNames
  • collections
  • collectionsInfo
  • command
  • createCollection
  • createIndex
  • cursorInfo
  • db
  • dereference
  • dropCollection
  • dropDatabase
  • dropIndex
  • ensureIndex
  • eval
  • indexInformation
  • lastError
  • logout
  • previousErrors
  • reIndex
  • removeUser
  • renameCollection
  • resetErrorHistory
  • stats

Collection

The following functions are available. For detailed interface information check the Node MongoDB Native Documentation

  • aggregate
  • count
  • createIndex
  • distinct
  • drop
  • dropAllIndexes
  • dropIndex
  • ensureIndex
  • find
  • findAndModify
  • findAndRemove
  • findOne
  • geoHaystackSearch
  • geoNear
  • group
  • indexes
  • indexExists
  • indexInformation
  • insert
  • isCapped
  • mapReduce
  • options
  • reIndex
  • remove
  • rename
  • save
  • stats
  • update

Cursor

The following functions are available. For detailed interface information check the Node MongoDB Native Documentation

  • batchSize
  • close
  • count
  • each
  • explain
  • isClosed
  • limit
  • nextObject
  • rewind
  • setReadPreference
  • skip
  • sort
  • stream
  • toArray

MongoDB Data Types

The following Data Types from the Node MongoDB Native driver are available:

  • BSON
  • ObjectID
  • Binary
  • Code
  • Double
  • Long
  • Timestamp
  • MaxKey
  • Symbol

License

The MIT License

Copyright(c) 2013-2014, Playlyfe Technologies, [email protected], http://dev.playlyfe.com/