Can I write native mongodb queries within payload without creating new connection? I would like to do some aggregations and also do some count queries.
Hey
@661298338939011077, I couldn't find the docs page for this but you have direct access to the mongoose model inside the local API via
collections.slug.Model
Does this fit within your needs?
you are lifesaver!!
Yep you have complete access to the models like
@858693520012476436described.
When accessing a model directly just know that things like access-control & hooks will not run (which is fine). Only
payload.
operations (create/read/update/delete etc.) trigger hooks and access control to run.
Is there any way to access the mongo connection NOT through a model (e.g. so you could run database level operations?)
that's a question for mongoose honestly but it's a good question
i bet mongoose has some way of doing that
payload itself doesn't though
Star
Discord
online
Get dedicated engineering support directly from the Payload team.