@payloadcms/db-mongodb
Advanced tools
Comparing version 3.0.0-canary.9beaa28 to 3.0.0-canary.9de3ffd
@@ -72,2 +72,3 @@ import fs from 'fs'; | ||
migrationDir, | ||
packageName: '@payloadcms/db-mongodb', | ||
payload, | ||
@@ -74,0 +75,0 @@ prodMigrations, |
@@ -419,9 +419,80 @@ import mongoose from 'mongoose'; | ||
upload: (field, schema, config, buildSchemaOptions)=>{ | ||
const baseSchema = { | ||
...formatBaseSchema(field, buildSchemaOptions), | ||
type: mongoose.Schema.Types.Mixed, | ||
ref: field.relationTo | ||
}; | ||
const hasManyRelations = Array.isArray(field.relationTo); | ||
let schemaToReturn = {}; | ||
if (field.localized && config.localization) { | ||
schemaToReturn = { | ||
type: config.localization.localeCodes.reduce((locales, locale)=>{ | ||
let localeSchema = {}; | ||
if (hasManyRelations) { | ||
localeSchema = { | ||
...formatBaseSchema(field, buildSchemaOptions), | ||
_id: false, | ||
type: mongoose.Schema.Types.Mixed, | ||
relationTo: { | ||
type: String, | ||
enum: field.relationTo | ||
}, | ||
value: { | ||
type: mongoose.Schema.Types.Mixed, | ||
refPath: `${field.name}.${locale}.relationTo` | ||
} | ||
}; | ||
} else { | ||
localeSchema = { | ||
...formatBaseSchema(field, buildSchemaOptions), | ||
type: mongoose.Schema.Types.Mixed, | ||
ref: field.relationTo | ||
}; | ||
} | ||
return { | ||
...locales, | ||
[locale]: field.hasMany ? { | ||
type: [ | ||
localeSchema | ||
], | ||
default: formatDefaultValue(field) | ||
} : localeSchema | ||
}; | ||
}, {}), | ||
localized: true | ||
}; | ||
} else if (hasManyRelations) { | ||
schemaToReturn = { | ||
...formatBaseSchema(field, buildSchemaOptions), | ||
_id: false, | ||
type: mongoose.Schema.Types.Mixed, | ||
relationTo: { | ||
type: String, | ||
enum: field.relationTo | ||
}, | ||
value: { | ||
type: mongoose.Schema.Types.Mixed, | ||
refPath: `${field.name}.relationTo` | ||
} | ||
}; | ||
if (field.hasMany) { | ||
schemaToReturn = { | ||
type: [ | ||
schemaToReturn | ||
], | ||
default: formatDefaultValue(field) | ||
}; | ||
} | ||
} else { | ||
schemaToReturn = { | ||
...formatBaseSchema(field, buildSchemaOptions), | ||
type: mongoose.Schema.Types.Mixed, | ||
ref: field.relationTo | ||
}; | ||
if (field.hasMany) { | ||
schemaToReturn = { | ||
type: [ | ||
schemaToReturn | ||
], | ||
default: formatDefaultValue(field) | ||
}; | ||
} | ||
} | ||
schema.add({ | ||
[field.name]: localizeSchema(field, baseSchema, config.localization) | ||
[field.name]: schemaToReturn | ||
}); | ||
@@ -428,0 +499,0 @@ } |
{ | ||
"name": "@payloadcms/db-mongodb", | ||
"version": "3.0.0-canary.9beaa28", | ||
"version": "3.0.0-canary.9de3ffd", | ||
"description": "The officially supported MongoDB database adapter for Payload", | ||
@@ -41,6 +41,6 @@ "homepage": "https://payloadcms.com", | ||
"@payloadcms/eslint-config": "3.0.0-beta.59", | ||
"payload": "3.0.0-canary.9beaa28" | ||
"payload": "3.0.0-canary.9de3ffd" | ||
}, | ||
"peerDependencies": { | ||
"payload": "3.0.0-canary.9beaa28" | ||
"payload": "3.0.0-canary.9de3ffd" | ||
}, | ||
@@ -47,0 +47,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
313785
3050