crud icon indicating copy to clipboard operation
crud copied to clipboard

feat(crud,crud-request,crud-typeorm): Added custom operators

Open rgolea opened this issue 5 years ago • 19 comments

This is a first attempt to add custom operators to allow users to extend functionality. I still need some help with some tests but I believe this should close #149.

It should allow you to do something like the following:

@Crud({
  ...
  customOperators: {
    <operator key>: (field: string, param: string) => <returns a string>
  }
})

so, for an example like the following:

@Crud({
  ...
  customOperators: {
    intersects: (field: string, param: string) => `ST_Intersects(${field}, ST_GeomFromGeoJSON(:${param}))`
  }
})

You should be able to do something like: ?filter=geom||intersects||<some geojson> in order to filter the entries that actually intersect that geojson.

PS: Added tests as well

rgolea avatar Sep 11 '19 02:09 rgolea

@zMotivat0r would you please tell me if this is at least the right path to go on? I would like to proceed with my project but I won’t want to proceed on a path that will be on direct conflict with the official path that you guys might take.

rgolea avatar Sep 15 '19 13:09 rgolea

First of all, @rgolea, thank you very much for your PR. I think the idea itself is awesome, but I haven't a chance to discover and review this PR closely. I'm working now on some magor bugs and hopefully will review your PR soon.

michaelyali avatar Sep 15 '19 13:09 michaelyali

Thank you very much! Great project btw! If you need some help with the project, let me know: I will try to help however I can.

rgolea avatar Sep 15 '19 15:09 rgolea

Hi there @zMotivat0r! Is there any news on this?

rgolea avatar Oct 04 '19 00:10 rgolea

Hello! This is a very good and necessary contribution, it is often required to write custom operators in postgres

Mr-Plutus avatar Nov 07 '19 18:11 Mr-Plutus

@rgolea You need rebase and resolve the conflicts

Diluka avatar Feb 10 '20 02:02 Diluka

@Diluka I had it updated for about a month. I don't know if you guys abandoned the project. I will update it soon but I would love to know if it can be merged soon.

rgolea avatar Feb 11 '20 12:02 rgolea

Chiming in to hopefully push this review forward! 😃 This looks like a great feature!

giard-alexandre avatar Feb 26 '20 00:02 giard-alexandre

@rgolea just checking if you are still working on this, and looking at the conflicts?

reececasey avatar May 20 '20 11:05 reececasey

@reececasey I am very sorry but I have been swamped with work. I will do my best to update this over the weekend.

rgolea avatar May 20 '20 20:05 rgolea

@zMotivat0r have you been able to take a look ?

Darkein avatar Jul 03 '20 15:07 Darkein

@Darkein yep, I was looking at this PR but unfortunately for it, at that moment I was working on a big update when I refactored a lot of parts and moved a lot of work to the interceptors and introduced search param mechanism as far as I remember. And now there is a lot of conflicts :(

michaelyali avatar Jul 04 '20 06:07 michaelyali

@zMotivat0r @Darkein and unfortunately I’m currently mixed up in a lot of work and cannot get to it at the moment. If anyone wants to try to do the same thing it would be much appreciated. I cannot define at the moment the time I need to finish updating this PR. I wouldn’t close it because it can still be used as an example on how to implement it and I will update it eventually if no one gets to it before I do.

rgolea avatar Jul 04 '20 13:07 rgolea

I will take a look this week :)

Darkein avatar Jul 05 '20 20:07 Darkein

@Darkein feel free to copy all the code you need and ask me if you need anything! This is a great feature to have.

rgolea avatar Jul 05 '20 20:07 rgolea

@zMotivat0r @rgolea I've created a new PR recently, can you check it ? https://github.com/nestjsx/crud/pull/568

Darkein avatar Jul 21 '20 08:07 Darkein

@Darkein you my friend are a freaking hero. Give this man a medal. I will check it out today.

rgolea avatar Jul 21 '20 10:07 rgolea

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

@rewiko You don't have to merge this one, #568 is a rebase of it

Darkein avatar Dec 07 '21 16:12 Darkein