These are chat archives for Automattic/mongoose

22nd
Jun 2015
douglasf
@douglasf
Jun 22 2015 06:04
@EricMcRay if that was for me, would you care to elaborate a bit please?
Erinç Fırtına
@EricMcRay
Jun 22 2015 06:53
@douglasf if you can share your query and schema maybe i can help
@fayimora Why do i use virtual or why do i store hashedpassword?
douglasf
@douglasf
Jun 22 2015 06:55
var query = Post.model.find(
      {$or: [
        { $and: [
          { tagsPlain: { $in: textTags } },
          { tagsPlain: { $not: { $in: excludeTags } } }
          ] },
        {$text: {$search: free, $language: 'swedish'}}
      ]}
      //{textScore: {$meta: 'textScore'}}
    )
    //.sort({textScore: {$meta: 'textScore'}})
    .where('isPublished', true);
meh
Fayi Femi-Balogun
@fayimora
Jun 22 2015 06:55
@EricMcRay the former.. i personally just have a field called password that actually has a hashed password
douglasf
@douglasf
Jun 22 2015 06:56
@EricMcRay thats the query, tagsPlain is just an array with strings, as is textTags
Erinç Fırtına
@EricMcRay
Jun 22 2015 07:23
@fayimora I use password as a setter to generate hashedpassword. Just that. Like in this example: https://github.com/DaftMonk/fullstack-demo/blob/master/server/api/user/user.model.js
Erinç Fırtına
@EricMcRay
Jun 22 2015 07:31
@douglasf did you try like this?
var query = Post.model.find(
      {$or: [
        { $and: [
          { tagsPlain: { $in: textTags } },
          { tagsPlain: { $not: { $in: excludeTags } } }
          ] },
        {$text: {$search: free, $language: 'swedish'}}
      ]},
      {textTags: {$meta: 'textScore'}}
    )
    .sort({textTags: {$meta: 'textScore'}})
    .where('isPublished', true);
douglasf
@douglasf
Jun 22 2015 07:39
@EricMcRay that would only sort on the text score I think (at least once mongoose 4.0.6 is on npm) . Ideally i want to sort on both with number of tag hits as primary. I have a sorting function that does the job, but that does not play well with pagination since it sorts after query is executed
Erinç Fırtına
@EricMcRay
Jun 22 2015 07:43
I think you can manage that with aggregation but that can cause some performance issue
douglasf
@douglasf
Jun 22 2015 07:44
I'm sad to say that performance is secondary at this point int the project ;)
douglasf
@douglasf
Jun 22 2015 07:54
Thanks @EricMcRay !
Erinç Fırtına
@EricMcRay
Jun 22 2015 07:55
@douglasf glad to help
Fayi Femi-Balogun
@fayimora
Jun 22 2015 08:00
@EricMcRay I see.. thanks