Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add return statements #8

Merged
merged 1 commit into from
Jun 7, 2016
Merged

Conversation

Catlite91
Copy link
Contributor

No description provided.

@i5ting i5ting merged commit 0ac806e into moajs:master Jun 7, 2016
@i5ting
Copy link
Member

i5ting commented Jun 7, 2016

@Catlite91 这样有什么需求场景么?

i5ting added a commit that referenced this pull request Jun 7, 2016
@Catlite91
Copy link
Contributor Author

Catlite91 commented Jun 7, 2016

@i5ting 这样我在find()的时候就能继续find(...).populate(...).exec(...)了,

  articleService
    .findOne({_id: articleId})
    .populate('author')
    .exec(function (err, data)){...}

api封装应该不能丢了返回的对象从而少了功能。:)

@i5ting
Copy link
Member

i5ting commented Jun 7, 2016

@Catlite91 在v2里实现了promise化,把find api优化了一下,可以查,也可以带populate的。另外,我觉得这种方法,还是写在schema的methods上回更好一些

https://github.com/moajs/mongoosedao/tree/master-promise

@Catlite91
Copy link
Contributor Author

Catlite91 commented Jun 7, 2016

@i5ting ahh,我研究一下bluebird。我的需求可能就是这样,

articleService
    .findOne({_id: articleId})
    .populate('author')
    .exec(function (err, data)){...}

简单的想想就直接在方法里return了。
可以尝试更优雅的实现:/

@i5ting
Copy link
Member

i5ting commented Jun 7, 2016

#9 @Catlite91 稍后会加上findOne的,目前find的都加完了,你要不要试试?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants