New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mongoskin

Package Overview
Dependencies
Maintainers
2
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongoskin - npm Package Compare versions

Comparing version

to
1.3.20

22

lib/collection.js

@@ -25,2 +25,24 @@ /*!

/**
* bind extend functions to collection
*
* e.g.
*
* db.bind('article').bind({
* getPostByAuthor: function(id, callback) {
* this.findOne({author_id: id}, callback);
* }
* });
*
*/
SkinCollection.prototype.bind = function(extendObject) {
for(var key in extendObject) {
if(typeof extendObject[key] == 'function') {
this[key] = extendObject[key].bind(this);
} else {
this[key] = extendObject[key];
}
}
}
SkinCollection.prototype._open = function(callback) {

@@ -27,0 +49,0 @@ var collection_args = this._collection_args.concat([callback]);

2

package.json
{
"name": "mongoskin",
"description": "The future layer above node-mongodb-native",
"version": "1.3.20-alpha",
"version": "1.3.20",
"author": "Gui Lin <guileen@gmail.com>",

@@ -6,0 +6,0 @@ "homepage": "https://github.com/kissjs/node-mongoskin",

@@ -5,15 +5,7 @@ # mongoskin

[![Dependencies](https://david-dm.org/kissjs/node-mongoskin.png)](https://david-dm.org/kissjs/node-mongoskin)
[![Coverage Status](https://coveralls.io/repos/kissjs/node-mongoskin/badge.png?branch=1.3.20)](https://coveralls.io/r/kissjs/node-mongoskin?branch=1.3.20)
[![Coverage Status](https://coveralls.io/repos/kissjs/node-mongoskin/badge.png?branch=master)](https://coveralls.io/r/kissjs/node-mongoskin?branch=master)
[![NPM version](https://badge.fury.io/js/mongoskin.png)](http://badge.fury.io/js/mongoskin)
![logo](https://raw.github.com/kissjs/node-mongoskin/master/logo.png)
[![NPM](https://nodei.co/npm/mongoskin.png?downloads=true&stars=true)](https://nodei.co/npm/mongoskin/)
This project is a wrapper for [node-mongodb-native](https://github.com/mongodb/node-mongodb-native).
The base API is same at the node-mongodb-native, you may want to familiarise yourself with the [node-mongodb-native documentation](http://mongodb.github.com/node-mongodb-native/) first.
## NOTE!! mongoskin API change from 1.3.20
Since node-mongodb-native has change a lot of API, mongoskin redesign from 1.3.20. The version number keep same with node-mongodb-native. And the API appearence is also keep same with node-mongodb-native
Install

@@ -33,5 +25,3 @@ ========

var mongo = require('mongoskin');
var MongoClient = mongo.MongoClient;
var db = MongoClient.connect("mongodb://localhost:27017/integration_tests", {native_parser:true});
var db = mongo.db("mongodb://localhost:27017/integration_tests", {native_parser:true});
db.bind('article');

@@ -63,7 +53,24 @@ db.article.find().toArray(function(err, items) {

Model helper:
```js
var mongo = require('mongoskin');
var db = mongo.db("mongodb://localhost:27017/integration_tests", {native_parser:true});
db.bind('article').bind({
getByAuthor: function(author_id, callback) {
this.findOne({author_id: author_id}, callback);
}
});
db.article.getByAuthor(author_id, function(err, article) {
console.log(article);
});
```
## Origin API part
For detail API reference see [node mongodb API](http://mongodb.github.io/node-mongodb-native/). Mongoskin is just change the API call chain.
We make some common use functioin in promise mode, we call it SkinClass of a normal Class. And the API is almost same with official API.
We make some common use functions in promise mode, we call it SkinClass of a normal Class. And the API is almost same with official API.
### module
origin:

@@ -90,6 +97,12 @@ ```js

### MongoClient.connect(...)
returns a `Db` instance
alias origin `MongoClient.connect(..., function(err, db) { .... })`
origin:
```js
MongoClient.connect(..., functioin(err, db) {
MongoClient.connect(..., function(err, db) {
})

@@ -104,2 +117,8 @@ ```

### db.collection(..., [callback])
returns a `Collection` instance
alias origin `db.collection(..., function(err, collection) {....})`
origin:

@@ -109,4 +128,4 @@

var db = new Db(...);
db.open(functioin(err, db) {
db.collection('myCollection', {strict: true}, functioin(err, myCollection) {
db.open(function(err, db) {
db.collection('myCollection', {strict: true}, function(err, myCollection) {
// myCollection.find() ...

@@ -124,14 +143,2 @@ });

## Promised methods
### MongoClient.connect(...)
returns a `Db` instance
alias origin `MongoClient.connect(..., function(err, db) { .... })`
### db.collection
returns a `Collection` instance
alias origin `db.collection(..., function(err, collection) {....})`
### collection.find
returns a `Cursor` instance
alias origin `collection.find(..., function(err, cursor) {....})`
## MongoSkin API part

@@ -141,2 +148,14 @@

alias `MongoClient.connect(...)`
### module.helper.toObjectId(hexStr)
convert `String` to `ObjectID` instance.
### db.bind(name, options)
alias `db[name] = db.collection(name, options)`
```js
db.bind('article')
db.article.find().toArray(function(err, items) {
assert.ok(err == null);
});
```
### db.admin(...)

@@ -148,2 +167,4 @@ alias `new Admin(db, ...)`

alias `new GridStore(db, ...)`
### collection.bind(extendObject)
each method of extendObject will be bind to collection.
### collection.findById(id, ...)

@@ -156,3 +177,6 @@ alias `collection.find({_id: toObjectID(id)}, ...)`

## NOTE!! mongoskin API change from 1.3.20
Since node-mongodb-native has change a lot of API, mongoskin redesign from 1.3.20. The version number keep same with node-mongodb-native. And the API appearence is also keep same with node-mongodb-native
### Removed API from mongoskin 1.3.20

@@ -159,0 +183,0 @@