I'm not overly sure how this has happened by our collection name for all the Payload data is set to
test
...
Can this be changed? If so where? I don't remember ever having to set the name for the table but it could have been an oversight.
The name of your db is contained within the
MONGODB_URI
If you need to change it, you
shouldbe able to do so manually from the Compass interface you have open, then update your
MONGODB_URI
string accordingly
Otherwise you could change your
MONGODB_URI
first, then use the
mongodump
and
mongorestore
cli commands to migrate the old database over to the new one
Payload will create a new database if one was not found using the connection string provided
Yes, you can do it inside
server.ts
. [More info](
https://payloadcms.com/docs/getting-started/installation#server)
payload.init({
secret: process.env.PAYLOAD_SECRET,
mongoURL: process.env.MONGODB_URI,
express: app,
onInit: () => {
payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`);
},
mongoOptions: {
dbName: "payload",
},
});
Interesting, I've never actually seen anyone do it that way.
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.