erikras / erikras/react-redux-universal-hot-example

how to include mongoose

Open
#1,132 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
12.1k
Forks
2.5k
PR merge metrics
No merged PRs in 30d

Description

I am trying to include mongoose, but when it goes to api folder, with es6 promise, it won't work.
How should I write the promise version callback?

I am using like this:
`import mongoose from 'mongoose';
mongoose.Promise = Promise;
var User = require('../../models/User.js');

export default function loadArticle(params) {
console.log('id! woyao de id', params.query);

return new Promise((resolve, reject) => {
User.find({}, function(){
resolve({raw:1});
})

})
}
`

the same code works fine in src/server.js like
`User.find('庞龙', function(err, results){
console.log(results);
if (err) return console.error(err);
});`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.