mongoose-elasticsearch-xp icon indicating copy to clipboard operation
mongoose-elasticsearch-xp copied to clipboard

es_extend and promise

Open tero opened this issue 7 years ago • 7 comments

Would it be possible to support promises with es_extend's value? I would like to add related document count with a query like:

{
    es_extend: {
      commentCount: {
        es_type: 'integer',
        es_value: document =>
          mongoose.models.Comments
            .count({ 'post.id': document._id })
            .exec(),
      },
    },
  },

Reason for this is that I would like show comment count along the post list. Also, I'm interested if there is a better way to achieve the same end result.

tero avatar Oct 03 '17 12:10 tero

No idea when I'll have bandwidth, but I'll keep it in mind...

jbdemonte avatar Oct 04 '17 04:10 jbdemonte

I think commentCount should be a regular Number field you update each time you receive a new comment from your controller.

michelem09 avatar Oct 10 '17 14:10 michelem09

@michelem09 your url on your github account doesn't work (http://www.michelem.org)

jbdemonte avatar Oct 10 '17 14:10 jbdemonte

I tried with some online tools and it seems to work fine, but thanks I will update the http(s)

michelem09 avatar Oct 10 '17 14:10 michelem09

I'm redirected to https://www.michelem/ without the .org

jbdemonte avatar Oct 10 '17 15:10 jbdemonte

Sh*t! You are right. Fixed. Thanks!

michelem09 avatar Oct 10 '17 15:10 michelem09

:D you're welcome

jbdemonte avatar Oct 10 '17 15:10 jbdemonte