crud icon indicating copy to clipboard operation
crud copied to clipboard

Jaybell/crud mongoose query params

Open yharaskrik opened this issue 4 years ago • 13 comments

yharaskrik avatar May 14 '20 03:05 yharaskrik

Hey @arrrrny coming back to this after a while I fixed #435 first but I will try and look into your populate issue and decoupling from typeORM

yharaskrik avatar May 14 '20 03:05 yharaskrik

This still needs quite a few unit tests to test the filter, or and search on GET's but the issues mentioned in #435 should be fixed.

yharaskrik avatar May 14 '20 03:05 yharaskrik

@yharaskrik thanks bro

arrrrny avatar May 14 '20 03:05 arrrrny

@yharaskrik please ping me when I can merge it

michaelyali avatar May 14 '20 03:05 michaelyali

@zMotivat0r will do. I would like to get the test coverage up a bit before that happens just to make sure that the filters are being built correctly. And to test that populate issue.

yharaskrik avatar May 14 '20 03:05 yharaskrik

Awesome

michaelyali avatar May 14 '20 03:05 michaelyali

I had to rework how the crud request interceptor works a small amount to ensure that some of the operators that are allowed can be used with mongoose.

There is now an OPERATOR_MAP optional injection token that can customize the crud request parsing. Since mongoose does not use SQL to query some operators do not map 1:1 like in TypeORM.

Can be provided like this:

{
   provide: OPERATOR_MAP,
   useValue: MONGOOSE_OPERATOR_MAP,
}

This injection token is optional and if not provided will use the operators as is to query the DB.

This will also allow for more Databases if they happen to use different syntax.

One side effect of this that may need to be addressed is that the operators that are used after transformation with the operator map may need to be whitelisted in the validate operator function in the interceptor.

This also decouples from TypeORM and adds DeepPartial to the utils.

Something to note: The operator map is only needed for mongoose if you are using operators that are not directly supported by mongoose. And not all operators are supported yet, the ones currently supported are:

  1. eq
  2. ne
  3. gt
  4. lt
  5. gte
  6. lte
  7. in
  8. notin
  9. isnull
  10. notnull
  11. between
  12. starts
  13. end
  14. cont
  15. excl

Not sure if this is quite the best way to go, open to suggestions of how we can breach the gap between NoSQL query language (currently mongodb) and SQL. With the changes that I made I do not think we would be able to use more than one DB type with this package, although not sure if that was possible before or not either.

yharaskrik avatar May 18 '20 23:05 yharaskrik

Is there any roadmap to merge this?

AliYusuf95 avatar Jun 08 '20 10:06 AliYusuf95

Any Updates here, would love to see this!

helgetan avatar Sep 02 '20 11:09 helgetan

Is there any news on this?

fasenderos avatar Mar 12 '21 08:03 fasenderos

I am trying to help and have forked this repo (can't reach the owner of this repo and do not have the credential for the npm repo).

See #710 (comment)

We can hopefully merge it via rewiko#5

rewiko avatar Nov 28 '21 09:11 rewiko

it has been two years! Why this is not merged?

nind0932 avatar Aug 29 '22 08:08 nind0932

We would like to use mongoose with NestJS, is it possible that you merge this PR? Thanks a lot.

afilp avatar May 18 '23 06:05 afilp