#Error: The collection with slug <db-name> can't be found.

4 messages · Page 1 of 1 (latest)

rich gazelle
#

Hi,

I am using payload.create local API to create a resource in my mongodb in the backend. For the first time a user uses my API, the db will not be there and therefore generates the error "The collection with slug <db-name> can't be found.".

Is there a param or a way in payload.create that I need to configure which checks if the db is there and if not, create it using the slug specified to insert the document? The same way Payload CMS is doing?

This is how I'm doing it for now:

await payload.create({
    collection: 'sellers',
    data: req.body,
});
twin plankBOT
rich gazelle
#

Error: The collection with slug <db-name> can't be found.

dusk lagoon
#

your collections are defined in your config, they should be available before using payload.create