File tree Expand file tree Collapse file tree 7 files changed +219
-91
lines changed
packages/db-mongodb/src/utilities Expand file tree Collapse file tree 7 files changed +219
-91
lines changed Original file line number Diff line number Diff line change @@ -19,13 +19,12 @@ export const handleError = ({
19
19
20
20
// Handle uniqueness error from MongoDB
21
21
if ( 'code' in error && error . code === 11000 && 'keyValue' in error && error . keyValue ) {
22
- const message = req ?. t ? req . t ( 'error:valueMustBeUnique' ) : 'Value must be unique'
23
22
throw new ValidationError (
24
23
{
25
24
collection,
26
25
errors : [
27
26
{
28
- message,
27
+ message : req ?. t ? req . t ( 'error:valueMustBeUnique' ) : 'Value must be unique' ,
29
28
path : Object . keys ( error . keyValue ) [ 0 ] ,
30
29
} ,
31
30
] ,
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ const collectionWithName = (collectionSlug: string): CollectionConfig => {
34
34
}
35
35
}
36
36
37
- export const slug = 'posts'
37
+ export const postsSlug = 'posts'
38
38
export const relationSlug = 'relation'
39
39
export const pointSlug = 'point'
40
40
export const customIdSlug = 'custom-id'
@@ -51,7 +51,7 @@ export default buildConfigWithDefaults({
51
51
} ,
52
52
collections : [
53
53
{
54
- slug,
54
+ slug : postsSlug ,
55
55
access : openAccess ,
56
56
fields : [
57
57
{
@@ -346,14 +346,14 @@ export default buildConfigWithDefaults({
346
346
347
347
// Relation - hasMany
348
348
await payload . create ( {
349
- collection : slug ,
349
+ collection : postsSlug ,
350
350
data : {
351
351
relationHasManyField : rel1 . id ,
352
352
title : 'rel to hasMany' ,
353
353
} ,
354
354
} )
355
355
await payload . create ( {
356
- collection : slug ,
356
+ collection : postsSlug ,
357
357
data : {
358
358
relationHasManyField : rel2 . id ,
359
359
title : 'rel to hasMany 2' ,
@@ -362,7 +362,7 @@ export default buildConfigWithDefaults({
362
362
363
363
// Relation - relationTo multi
364
364
await payload . create ( {
365
- collection : slug ,
365
+ collection : postsSlug ,
366
366
data : {
367
367
relationMultiRelationTo : {
368
368
relationTo : relationSlug ,
@@ -374,7 +374,7 @@ export default buildConfigWithDefaults({
374
374
375
375
// Relation - relationTo multi hasMany
376
376
await payload . create ( {
377
- collection : slug ,
377
+ collection : postsSlug ,
378
378
data : {
379
379
relationMultiRelationToHasMany : [
380
380
{
You can’t perform that action at this time.
0 commit comments