Closed xtonousou closed 7 months ago
You may have a misconception here. The collection hooks are part of the Go code inside the pocketbase server library. They are not accessible from any web API. If you want to use them you need to compile your own pocketbase server with the relevant modifications.
The web API supports what is called "realtime service". Examples can be found in our codebase here tests/integration/test_record_event.py
.
these are however only notifications that are received once an record was changed, they do not allow to place middleware inside the record modification action (or even stop it from happening) like the Go server library can do.
Thanks for clarifying this. I may have to use the realtime service to listen for the events (triggered natively by pocketbase) that I need and then implement the logic there.
Brief
While reading the PocketBase docs, I stumbled upon collection hooks mechanism and I'm very curious, how do you implement this with the python sdk?
Use case
For example, a base collection has the field
password
of typetext
and when a record is inserted, you have to "call" an event hook that hashes the password and then saves it to PocketBase. And vice versa, when a record from that collection is listed/read then you have to "call" an event hook to decrypt it in order to show the plain text.Conclude
It is a matter of time until PocketBase adds the
password
type field forbase
collections, but until then I think this is a nice feature to have with an alternative solution using "encrypting" hooks. I spotted the packagepluggy
in poetry but nothing uses it so I assume that it'sWIP
?