fix(db-mongodb): mongodb optimizations (#10120)
There are few issues introduced in #9594 that we need to look into with these changes.
This commit is contained in:
@@ -53,12 +53,10 @@ describe('Relationship Fields', () => {
|
||||
collection: versionedRelationshipFieldSlug,
|
||||
data: {
|
||||
title: 'Version 1 Title',
|
||||
relationshipField: [
|
||||
{
|
||||
value: relatedDoc.id,
|
||||
relationTo: collection1Slug,
|
||||
},
|
||||
],
|
||||
relationshipField: {
|
||||
value: relatedDoc.id,
|
||||
relationTo: collection1Slug,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
@@ -1134,30 +1134,6 @@ describe('Fields', () => {
|
||||
expect(doc.localized).toEqual(localized)
|
||||
expect(doc.group).toMatchObject(group)
|
||||
})
|
||||
|
||||
it('should clear a point field', async () => {
|
||||
if (payload.db.name === 'sqlite') {
|
||||
return
|
||||
}
|
||||
|
||||
const doc = await payload.create({
|
||||
collection: 'point-fields',
|
||||
data: {
|
||||
point: [7, -7],
|
||||
group: {
|
||||
point: [7, -7],
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
const res = await payload.update({
|
||||
collection: 'point-fields',
|
||||
id: doc.id,
|
||||
data: { group: { point: null } },
|
||||
})
|
||||
|
||||
expect(res.group.point).toBeFalsy()
|
||||
})
|
||||
})
|
||||
|
||||
describe('unique indexes', () => {
|
||||
|
||||
@@ -174,10 +174,7 @@ describe('Joins Field', () => {
|
||||
collection: categoriesSlug,
|
||||
})
|
||||
|
||||
expect(categoryWithPosts).toStrictEqual({
|
||||
id: categoryWithPosts.id,
|
||||
group: categoryWithPosts.group,
|
||||
})
|
||||
expect(Object.keys(categoryWithPosts)).toStrictEqual(['id', 'group'])
|
||||
|
||||
expect(categoryWithPosts.group.relatedPosts.docs).toHaveLength(10)
|
||||
expect(categoryWithPosts.group.relatedPosts.docs[0]).toHaveProperty('id')
|
||||
|
||||
@@ -1633,10 +1633,7 @@ describe('Select', () => {
|
||||
},
|
||||
})
|
||||
|
||||
expect(res).toStrictEqual({
|
||||
id: res.id,
|
||||
text: res.text,
|
||||
})
|
||||
expect(Object.keys(res)).toStrictEqual(['id', 'text'])
|
||||
})
|
||||
|
||||
it('should apply select with updateByID', async () => {
|
||||
@@ -1649,18 +1646,13 @@ describe('Select', () => {
|
||||
select: { text: true },
|
||||
})
|
||||
|
||||
expect(res).toStrictEqual({
|
||||
id: res.id,
|
||||
text: res.text,
|
||||
})
|
||||
expect(Object.keys(res)).toStrictEqual(['id', 'text'])
|
||||
})
|
||||
|
||||
it('should apply select with updateBulk', async () => {
|
||||
const post = await createPost()
|
||||
|
||||
const {
|
||||
docs: [res],
|
||||
} = await payload.update({
|
||||
const res = await payload.update({
|
||||
collection: 'posts',
|
||||
where: {
|
||||
id: {
|
||||
@@ -1671,10 +1663,7 @@ describe('Select', () => {
|
||||
select: { text: true },
|
||||
})
|
||||
|
||||
expect(res).toStrictEqual({
|
||||
id: res.id,
|
||||
text: res.text,
|
||||
})
|
||||
expect(Object.keys(res.docs[0])).toStrictEqual(['id', 'text'])
|
||||
})
|
||||
|
||||
it('should apply select with deleteByID', async () => {
|
||||
@@ -1686,18 +1675,13 @@ describe('Select', () => {
|
||||
select: { text: true },
|
||||
})
|
||||
|
||||
expect(res).toStrictEqual({
|
||||
id: res.id,
|
||||
text: res.text,
|
||||
})
|
||||
expect(Object.keys(res)).toStrictEqual(['id', 'text'])
|
||||
})
|
||||
|
||||
it('should apply select with deleteBulk', async () => {
|
||||
const post = await createPost()
|
||||
|
||||
const {
|
||||
docs: [res],
|
||||
} = await payload.delete({
|
||||
const res = await payload.delete({
|
||||
collection: 'posts',
|
||||
where: {
|
||||
id: {
|
||||
@@ -1707,10 +1691,7 @@ describe('Select', () => {
|
||||
select: { text: true },
|
||||
})
|
||||
|
||||
expect(res).toStrictEqual({
|
||||
id: res.id,
|
||||
text: res.text,
|
||||
})
|
||||
expect(Object.keys(res.docs[0])).toStrictEqual(['id', 'text'])
|
||||
})
|
||||
|
||||
it('should apply select with duplicate', async () => {
|
||||
@@ -1722,10 +1703,7 @@ describe('Select', () => {
|
||||
select: { text: true },
|
||||
})
|
||||
|
||||
expect(res).toStrictEqual({
|
||||
id: res.id,
|
||||
text: res.text,
|
||||
})
|
||||
expect(Object.keys(res)).toStrictEqual(['id', 'text'])
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user