LearnBoost/mongoose — Issue #642: .select() doesn't work when chained off a namedScope
Author: pennyfx
Created: 2011-12-11 05:31:13+00:00
State: open

```javascript

var mongoose = module.exports.mongoose = require('mongoose');

var User = new mongoose.Schema({
_type	: { 'type': String, 'default': 'user' },
username	: { 'type': String, 'index': { unique: true } },
provider_data	: {},
lastLogin	: Date,
created_at	: { 'type': Date, 'default': Date.now }
});

User.namedScope('byId', function(id){
return this.where('_id',id);
});

mongoose.model('User', User);

var UserModel = mongoose.model('User');

UserModel.where('_id','4ec348d44affdbd287000013').select('username','_id').find(function(err,res){
console.log(err,res);
});

UserModel.byId('4ec348d44affdbd287000013').select('username','_id').find(function(err,res){
console.log(err,res);
});

```