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

Better query support #5

Open
dylanlott opened this issue Dec 28, 2017 · 4 comments
Open

Better query support #5

dylanlott opened this issue Dec 28, 2017 · 4 comments
Assignees
Milestone

Comments

@dylanlott
Copy link
Collaborator

dylanlott commented Dec 28, 2017

Querying should be much more robust by default.

  • User's should be able to populate and accomplish relational data using their own queries.
  • User's should be able to use advanced querying mechanics such as $IN and $WHERE and $EXISTS
@dylanlott dylanlott added this to the 2.0 milestone Dec 28, 2017
@GabeAboy
Copy link
Contributor

GabeAboy commented Sep 26, 2019

@GabeAboy
Copy link
Contributor

GabeAboy commented Sep 27, 2019

Logical Operators
[X] $not | Negation logical operator | {"field" : {"$not" : val}}
[X] $in | Match any value in array | {"field" : {"$in" : [value1, value2, ...]}}
---/ubermind/?=value1/value2
[X] $nin | Not match any value in array | {"field" : {"$nin" : [value1, value2, ...]}}
[ ] $regex | Match field | {"field" : {"$regex" : ".*"}}
[X] $or | Logical operator | {"$or": [{"status": "GOLD"}, {"status": "SILVER"}]}
---Docs say use $in in replace for $or

[X] $and | Logical operator | {"$and": [{"status": "GOLD"}, {"sales": 1000}]}
[X] $where | Match any value | {"field" : value}
---/ubermind/?=value

@GabeAboy
Copy link
Contributor

GabeAboy commented Sep 27, 2019

I might change the request string to look something like this https://restdb.io/docs/querying-with-the-api#queryXexamples. What do you think @dylanlott

TLDR
It expects the user to use an http string such as,
http://localhost:3000/ubermind/todos?q={"task" : {"$in" : ["Learn Spanish", "Learn Ubermind"]}}
Which is nice, but I think the goal is to reduce the amount of knowledge of mongo necessary to use ubermind. Using above is super easy but puts the responsibility to the client in injecting a properly formatted query argument.

I want to make it simpler, but I don't know-how. This is my initial thought. I might change the / to ||
What is set up in the PR
http://localhost:3000/ubermind/todos?task=Learn Spanish/Learn ubermind

Or use the req.body for it?

@GabeAboy
Copy link
Contributor

GabeAboy commented Sep 28, 2019

Conditional Operators

Priority
[X] $gt | > | {"salary": {"$gt": 10000}}
[X] $gte | >= | {"salary": {"$gte": 10000}}
[X] $lt | < | {"salary": {"$lt": 10000}}
[X] $lte | <= | {"salary": {"$lte": 10000}}
[ ] $bt | >= value <= | {"salary": {"$bt": [5000, 7500]}}

Extra
[ ] $exists | Check if field exists | {"field": {"$exists": true|false}}
---/ubermind/?task=exists
[ ] $exists (array) | Check if array field exists or is empty | {"field.0": {"$exists": true|false}}
---/ubermind/?task=one||two||three
HOW?
[ ] $elemMatch | Array element matching | {"contact":{"$elemMatch":{"name":"Anderson", age:35}}}
[ ] $distinct | Array with unique element values | {"$distinct": "name"}
---/ubermind/?task=
HOW?

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

No branches or pull requests

2 participants