Permalink
Browse files

fixed unsafe mode warnning log

  • Loading branch information...
1 parent 71858e9 commit 82dd0a03e72da52912719360ae5eed5fc155e011 @fengmk2 fengmk2 committed Dec 29, 2012
Showing with 35 additions and 18 deletions.
  1. +2 −0 .travis.yml
  2. +5 −3 Readme.md
  3. BIN logo.png
  4. +26 −13 test/collection.js
  5. +1 −1 test/cursor.js
  6. +1 −1 test/db.js
View
2 .travis.yml
@@ -2,3 +2,5 @@ language: node_js
node_js:
- 0.6
- 0.8
+services:
+ - mongodb
View
8 Readme.md
@@ -1,6 +1,6 @@
-# mongoskin
+# mongoskin [![Build Status](https://secure.travis-ci.org/kissjs/node-mongoskin.png)](http://travis-ci.org/kissjs/node-mongoskin)
-[![Build Status](https://secure.travis-ci.org/kissjs/node-mongoskin.png)](http://travis-ci.org/kissjs/node-mongoskin)
+![logo](https://raw.github.com/kissjs/node-mongoskin/master/logo.png)
This project is a wrapper of [node-mongodb-native](https://github.com/mongodb/node-mongodb-native).
The api is same to node-mongodb-native, please see the [document](http://mongodb.github.com/node-mongodb-native/) first.
@@ -268,7 +268,8 @@ var db = mongoskin.db([
'192.168.0.2:27017/?auto_reconnect=true',
'192.168.0.3:27017/?auto_reconnect=true'
], {
- database: 'testdb'
+ database: 'testdb',
+ safe: true
}, {
connectArbiter: false,
socketOptions: {
@@ -610,6 +611,7 @@ collection.group([], {}, {"count":0}, "function (obj, prev) { prev.count++; }",
Options:
upsert - true/false (perform upsert operation)
multi - true/false (update all documents matching spec)
+ strict - true/false (perform check if the operation failed, required extra call to db)
Deprecated Options:
safe - true/false (perform check if the operation failed, required extra call to db)
**/
View
BIN logo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
39 test/collection.js
@@ -29,18 +29,20 @@ describe('collection.js', function () {
});
var cases = [
- ['normal', {database: 'mongoskin_test'}],
+ ['normal', {database: 'mongoskin_test', safe: true}],
];
if (servermanager.MONGOSKIN_REPLICASET) {
- cases.push(['replicaset', {database: 'mongoskin_replicaset_test'}]);
+ cases.push(['replicaset', {database: 'mongoskin_replicaset_test', strict: true}]);
}
+
cases.forEach(function (caseItem) {
describe(caseItem[0], function () {
var isReplicaset = caseItem[0] === 'replicaset';
var db = null;
var servers = null;
var authfailServers = null;
var options = caseItem[1];
+
before(function (done) {
if (isReplicaset) {
servers = [];
@@ -54,13 +56,14 @@ describe('collection.js', function () {
}
db = mongoskin.db(servers, options);
db.bind('testcollection');
- db.testcollection.ensureIndex({title: -1});
- db.testcollection.findItems(function (err, rows) {
- if (err) {
- return done(err);
- }
- rows.should.be.instanceof(Array).with.length(0);
- done();
+ db.testcollection.ensureIndex({title: -1}, function (err, index) {
+ should.not.exist(err);
+ index.should.equal('title_-1');
+ db.testcollection.findItems(function (err, rows) {
+ should.not.exist(err);
+ rows.should.be.instanceof(Array).with.length(0);
+ done();
+ });
});
});
@@ -356,9 +359,10 @@ describe('collection.js', function () {
updated_at: updatedTime
}
};
- db.article.updateById(articleId.toString(), doc, function (err, article) {
+ db.article.updateById(articleId.toString(), doc, function (err, success, result) {
should.not.exist(err);
- should.not.exist(article);
+ success.should.equal(1);
+ result.should.have.property('ok', 1);
db.article.findById(articleId, function (err, article) {
should.not.exist(err);
should.exist(article);
@@ -377,9 +381,9 @@ describe('collection.js', function () {
db.article.findById(id, function (err, article) {
should.not.exist(err);
should.exist(article);
- db.article.removeById(id, function (err, article) {
+ db.article.removeById(id, function (err, success) {
should.not.exist(err);
- should.not.exist(article);
+ success.should.equal(1);
db.article.findById(id, function (err, article) {
should.not.exist(err);
should.not.exist(article);
@@ -388,6 +392,15 @@ describe('collection.js', function () {
});
});
});
+
+ it('should remove not exists obj', function (done) {
+ var id = articleId.toString();
+ db.article.removeById(id, function (err, success) {
+ should.not.exist(err);
+ success.should.equal(0);
+ done();
+ });
+ });
});
});
View
2 test/cursor.js
@@ -30,7 +30,7 @@ describe('cursor.js', function () {
});
var cases = [
- ['normal', {database: 'mongoskin_test'}],
+ ['normal', {database: 'mongoskin_test', safe: true}],
];
if (servermanager.MONGOSKIN_REPLICASET) {
cases.push(['replicaset', {database: 'mongoskin_replicaset_test'}]);
View
2 test/db.js
@@ -36,7 +36,7 @@ describe('db.js', function () {
});
var cases = [
- ['normal', {database: 'mongoskin_test'}],
+ ['normal', {database: 'mongoskin_test', safe: true}],
];
if (servermanager.MONGOSKIN_REPLICASET) {
cases.push(['replicaset', {database: 'mongoskin_replicaset_test'}]);

0 comments on commit 82dd0a0

Please sign in to comment.