K
K
Klein Maximus2016-04-13 21:09:10
MongoDB
Klein Maximus, 2016-04-13 21:09:10

Why can a query to MongoDB through Mongoose hang?

AccessToken - Mongoose Model

var mongoose = require('mongoose');
var Schema = mongoose.Schema;

// AccessToken
var AccessToken = new Schema({
    userId: {
        type: String,
        required: true
    },

    clientId: {
        type: String,
        required: true
    },

    token: {
        type: String,
        unique: true,
        required: true
    },
    
    created: {
        type: Date,
        default: Date.now
    }
});

module.exports  = mongoose.model('AccessToken', AccessToken);

This code freezes.
That is, either the database does not give back data, or Mongoose freezes.
passport.use(
    new BearerStrategy(
        function( accessToken, done ) {
            // Здесь в консоль нормально выводится accessToken и done
            AccessToken.findOne( { token: accessToken }, function( err, token ) {
                // До этой точки не доходит - ЗАВИСАЕТ
            }
        }
    )
);

If instead of AccessToken.findOne we insert a direct connection to MongoDB, then everything works :(
What could be the problem?
Maybe Mongoose needs to be configured somehow?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Klein Maximus, 2016-04-13
@kleinmaximus

The question is removed.
It's all about care :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question