apostrophecms / apostrophecms/apostrophe

"and" filter method not working with joinByOne or joinByArray

Open
#2,105 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
4.6k
Forks
650
Avg merge
19h 21m
Merged PRs (30d)
23

Description

The filters **and** options not work.
```
{
name: "_best_product",
withType: "product",
type: "joinByOne",
filters: {
and: { score: { $gte: 5 } },
projection: {
title: 1,
slug: 1,
type: 1,
tags: 1
}
}
}
```

**To Reproduce**
I created a git to run a test: https://github.com/FerX/apostrophe-test-and

Steps to reproduce the behavior:
1. clone git
2. npm install
3. create user admin
4. run project
5. add many piece products with score from 1 to 10
6. in the home page, open Page Settings
7. tab info - best product - Browse
8. you will see that it displays all the pieces and not filtered based on the AND rule entered in lib/modules/home-pages/index.js

**Expected behavior**
list of products with score >=5

**Describe the bug**
the **and** filter is not used to compose the mongodb filters

**Version of Node.js**
v11.15.0

**Server Operating System**
Linux Debian stable

Contributor guide

Open the contributing guide

Research direction

Start with the reproduction project at https://github.com/FerX/apostrophe-test-and and inspect lib/modules/home-pages/index.js, where the filter is entered. Run npm install and follow the reported steps, then verify that joinByOne or joinByArray displays only products with score >= 5; done when the AND filter produces that result.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, mongodb, node.js
Domain
backend, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.