crud
crud copied to clipboard
feat(crud,crud-request,crud-typeorm): Added custom operators
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
@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.
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.
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.
Hi there @zMotivat0r! Is there any news on this?
Hello! This is a very good and necessary contribution, it is often required to write custom operators in postgres
@rgolea You need rebase and resolve the conflicts
@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.
Chiming in to hopefully push this review forward! 😃 This looks like a great feature!
@rgolea just checking if you are still working on this, and looking at the conflicts?
@reececasey I am very sorry but I have been swamped with work. I will do my best to update this over the weekend.
@zMotivat0r have you been able to take a look ?
@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 :(
@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.
I will take a look this week :)
@Darkein feel free to copy all the code you need and ask me if you need anything! This is a great feature to have.
@zMotivat0r @rgolea I've created a new PR recently, can you check it ? https://github.com/nestjsx/crud/pull/568
@Darkein you my friend are a freaking hero. Give this man a medal. I will check it out today.
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 You don't have to merge this one, #568 is a rebase of it