chore: renames mongoose db adapter refs to mongodb
This commit is contained in:
@@ -32,7 +32,7 @@ import sharp from 'sharp'
|
|||||||
// process.env.PAYLOAD_DATABASE = 'postgres'
|
// process.env.PAYLOAD_DATABASE = 'postgres'
|
||||||
|
|
||||||
const databaseAdapters = {
|
const databaseAdapters = {
|
||||||
mongoose: mongooseAdapter({
|
mongodb: mongooseAdapter({
|
||||||
url: process.env.DATABASE_URI || 'mongodb://127.0.0.1/payloadtests',
|
url: process.env.DATABASE_URI || 'mongodb://127.0.0.1/payloadtests',
|
||||||
}),
|
}),
|
||||||
postgres: postgresAdapter({
|
postgres: postgresAdapter({
|
||||||
@@ -65,14 +65,13 @@ let mongoMemoryServer = global._mongoMemoryServer
|
|||||||
export async function buildConfigWithDefaults(
|
export async function buildConfigWithDefaults(
|
||||||
testConfig?: Partial<Config>,
|
testConfig?: Partial<Config>,
|
||||||
): Promise<SanitizedConfig> {
|
): Promise<SanitizedConfig> {
|
||||||
console.log({
|
Object.entries(process.env).forEach(([key, val]) => {
|
||||||
mongoMemoryServer,
|
if (key.startsWith('PW')) {
|
||||||
payloadDatabase: process.env.PAYLOAD_DATABASE,
|
console.log({ key, val })
|
||||||
jestWorkerID: process.env.JEST_WORKER_ID,
|
}
|
||||||
pwTestSourceTransform: process.env.PW_TEST_SOURCE_TRANSFORM,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!process.env.PAYLOAD_DATABASE || process.env.PAYLOAD_DATABASE === 'mongoose') {
|
if (!process.env.PAYLOAD_DATABASE || process.env.PAYLOAD_DATABASE === 'mongodb') {
|
||||||
if (process.env.JEST_WORKER_ID || process.env.PW_TEST_SOURCE_TRANSFORM) {
|
if (process.env.JEST_WORKER_ID || process.env.PW_TEST_SOURCE_TRANSFORM) {
|
||||||
if (!mongoMemoryServer) {
|
if (!mongoMemoryServer) {
|
||||||
mongoMemoryServer = await MongoMemoryReplSet.create({
|
mongoMemoryServer = await MongoMemoryReplSet.create({
|
||||||
@@ -86,7 +85,7 @@ export async function buildConfigWithDefaults(
|
|||||||
|
|
||||||
console.log({ url })
|
console.log({ url })
|
||||||
|
|
||||||
databaseAdapters.mongoose = mongooseAdapter({
|
databaseAdapters.mongodb = mongooseAdapter({
|
||||||
mongoMemoryServer,
|
mongoMemoryServer,
|
||||||
url,
|
url,
|
||||||
})
|
})
|
||||||
@@ -95,7 +94,7 @@ export async function buildConfigWithDefaults(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const config: Config = {
|
const config: Config = {
|
||||||
db: databaseAdapters[process.env.PAYLOAD_DATABASE || 'mongoose'],
|
db: databaseAdapters[process.env.PAYLOAD_DATABASE || 'mongodb'],
|
||||||
secret: 'TEST_SECRET',
|
secret: 'TEST_SECRET',
|
||||||
//editor: slateEditor({}),
|
//editor: slateEditor({}),
|
||||||
// editor: slateEditor({
|
// editor: slateEditor({
|
||||||
|
|||||||
@@ -562,7 +562,7 @@ describe('collections-graphql', () => {
|
|||||||
expect(docs).toContainEqual(expect.objectContaining({ id: specialPost.id }))
|
expect(docs).toContainEqual(expect.objectContaining({ id: specialPost.id }))
|
||||||
})
|
})
|
||||||
|
|
||||||
if (['mongoose'].includes(process.env.PAYLOAD_DATABASE)) {
|
if (['mongodb'].includes(process.env.PAYLOAD_DATABASE)) {
|
||||||
describe('near', () => {
|
describe('near', () => {
|
||||||
const point = [10, 20]
|
const point = [10, 20]
|
||||||
const [lat, lng] = point
|
const [lat, lng] = point
|
||||||
|
|||||||
@@ -980,7 +980,7 @@ describe('collections-rest', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
if (['mongoose'].includes(process.env.PAYLOAD_DATABASE)) {
|
if (['mongodb'].includes(process.env.PAYLOAD_DATABASE)) {
|
||||||
describe('near', () => {
|
describe('near', () => {
|
||||||
const point = [10, 20]
|
const point = [10, 20]
|
||||||
const [lat, lng] = point
|
const [lat, lng] = point
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import type { Payload } from 'payload'
|
import type { Payload } from 'payload'
|
||||||
|
|
||||||
export function isMongoose(_payload?: Payload) {
|
export function isMongoose(_payload?: Payload) {
|
||||||
return _payload?.db?.name === 'mongoose' || ['mongoose'].includes(process.env.PAYLOAD_DATABASE)
|
return _payload?.db?.name === 'mongodb' || ['mongodb'].includes(process.env.PAYLOAD_DATABASE)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ export default async () => {
|
|||||||
process.env.NODE_OPTIONS = '--no-deprecation'
|
process.env.NODE_OPTIONS = '--no-deprecation'
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(!process.env.PAYLOAD_DATABASE || process.env.PAYLOAD_DATABASE === 'mongoose') &&
|
(!process.env.PAYLOAD_DATABASE || process.env.PAYLOAD_DATABASE === 'mongodb') &&
|
||||||
!global._mongoMemoryServer
|
!global._mongoMemoryServer
|
||||||
) {
|
) {
|
||||||
global._mongoMemoryServer = await MongoMemoryReplSet.create({
|
global._mongoMemoryServer = await MongoMemoryReplSet.create({
|
||||||
|
|||||||
Reference in New Issue
Block a user