Skip to content

Features/upgrade packages #59

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

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
language: node_js

node_js:
- 7
- 6
- 4
- 0.10
- 8
- 10

services:
- docker

env:
- MONGODB_VERSION="2.4"
- MONGODB_VERSION="2.6"
- MONGODB_VERSION="3.0"
- MONGODB_VERSION="3.2"
- MONGODB_VERSION="3.4"
- MONGODB_VERSION="3.6"
- MONGODB_VERSION="4.0"

before_install:
- docker run -d -p 127.0.0.1:27017:27017 mongo:$MONGODB_VERSION

before_script:
- until nc -z localhost 27017; do echo Waiting for MongoDB; sleep 1; done

# Run twice due to Mongo flakiness
script: "npm run test-cover || npm run test-cover"
script:
- travis_retry npm run test-cover

# Send coverage data to Coveralls
after_script: "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js"
after_script:
- cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
130 changes: 0 additions & 130 deletions README.md

This file was deleted.

21 changes: 16 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var async = require('async');
var mongodb = require('mongodb');
var DB = require('sharedb').DB;
var DB = require('@teamwork/sharedb').DB;

module.exports = ShareDbMongo;

Expand Down Expand Up @@ -70,7 +70,7 @@ ShareDbMongo.prototype.getCollection = function(collectionName, callback) {
// Gotcha: calls back sync if connected or async if not
this.getDbs(function(err, mongo) {
if (err) return callback(err);
var collection = mongo.collection(collectionName);
var collection = mongo.db().collection(collectionName);
return callback(null, collection);
});
};
Expand All @@ -82,7 +82,7 @@ ShareDbMongo.prototype._getCollectionPoll = function(collectionName, callback) {
// Gotcha: calls back sync if connected or async if not
this.getDbs(function(err, mongo, mongoPoll) {
if (err) return callback(err);
var collection = (mongoPoll || mongo).collection(collectionName);
var collection = (mongoPoll || mongo).db().collection(collectionName);
return callback(null, collection);
});
};
Expand Down Expand Up @@ -306,7 +306,7 @@ ShareDbMongo.prototype.getOpCollection = function(collectionName, callback) {
this.getDbs(function(err, mongo) {
if (err) return callback(err);
var name = self.getOplogCollectionName(collectionName);
var collection = mongo.collection(name);
var collection = mongo.db().collection(name);
// Given the potential problems with creating indexes on the fly, it might
// be preferrable to disable automatic creation
if (self.disableIndexCreation) {
Expand Down Expand Up @@ -1274,7 +1274,18 @@ var collectionOperationsMap = {
collection.distinct(value.field, query, cb);
},
'$aggregate': function(collection, query, value, cb) {
collection.aggregate(value, cb);
collection.aggregate(value, function(err, cursor) {
if(err) {
return cb(err);
}
cursor.toArray(function (err, res) {
if(err) {
return cb(err);
}
return cb(null, res);
});

});
},
'$mapReduce': function(collection, query, value, cb) {
if (typeof value !== 'object') {
Expand Down
Loading