feat(db-mongodb)!: update mongoose to 8.8.1 (#9115)
### What? Upgrades mongoose from 6 to latest `v8.8.1` Fixes https://github.com/payloadcms/payload/issues/9171 ### Why? Compatibilty with Mongodb Atlas ### How? - Updates deps - Changed ObjectId from bson-objectid to use `new Type.ObjectId` from mongoose for compatibility (only inside of db-mongodb) - Internal type adjustments https://github.com/payloadcms/payload/discussions/9088 BREAKING CHANGES: All projects with existing data having versions enabled, or relationship or upload fields will want to create the predefined migration that converts all strings to ObjectIDs where needed. This can be created using `payload migrate:create --file @payloadcms/mongodb/relationships-v2-v3`. For projects making use of the exposed Models from mongoose, review the upgrade guides from [v6 to v7](https://mongoosejs.com/docs/7.x/docs/migrating_to_7.html) and [v7 to v8](https://mongoosejs.com/docs/migrating_to_8.html) and make adjustments as needed. --------- Co-authored-by: Sasha <64744993+r1tsuu@users.noreply.github.com>
This commit is contained in:
@@ -84,6 +84,22 @@ export default buildConfigWithDefaults({
|
||||
type: 'relationship',
|
||||
relationTo: relationSlug,
|
||||
},
|
||||
{
|
||||
name: 'blocks',
|
||||
type: 'blocks',
|
||||
blocks: [
|
||||
{
|
||||
slug: 'block',
|
||||
fields: [
|
||||
{
|
||||
name: 'relationField',
|
||||
type: 'relationship',
|
||||
relationTo: relationSlug,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
// Relationship w/ default access
|
||||
{
|
||||
name: 'defaultAccessRelation',
|
||||
|
||||
@@ -334,6 +334,35 @@ describe('Relationships', () => {
|
||||
expect(query.docs).toHaveLength(1) // Due to limit: 1
|
||||
})
|
||||
|
||||
it('should allow querying within blocks', async () => {
|
||||
const rel = await payload.create({
|
||||
collection: relationSlug,
|
||||
data: {
|
||||
name: 'test',
|
||||
disableRelation: false,
|
||||
},
|
||||
})
|
||||
|
||||
const doc = await payload.create({
|
||||
collection: slug,
|
||||
data: {
|
||||
blocks: [
|
||||
{
|
||||
blockType: 'block',
|
||||
relationField: rel.id,
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
|
||||
const { docs } = await payload.find({
|
||||
collection: slug,
|
||||
where: { 'blocks.relationField': { equals: rel.id } },
|
||||
})
|
||||
|
||||
expect(docs[0].id).toBe(doc.id)
|
||||
})
|
||||
|
||||
describe('Custom ID', () => {
|
||||
it('should query a custom id relation', async () => {
|
||||
const { customIdRelation } = await restClient
|
||||
|
||||
@@ -97,6 +97,14 @@ export interface Post {
|
||||
description?: string | null;
|
||||
number?: number | null;
|
||||
relationField?: (string | null) | Relation;
|
||||
blocks?:
|
||||
| {
|
||||
relationField?: (string | null) | Relation;
|
||||
id?: string | null;
|
||||
blockName?: string | null;
|
||||
blockType: 'block';
|
||||
}[]
|
||||
| null;
|
||||
defaultAccessRelation?: (string | null) | StrictAccess;
|
||||
chainedRelation?: (string | null) | Chained;
|
||||
maxDepthRelation?: (string | null) | Relation;
|
||||
@@ -429,6 +437,17 @@ export interface PostsSelect<T extends boolean = true> {
|
||||
description?: T;
|
||||
number?: T;
|
||||
relationField?: T;
|
||||
blocks?:
|
||||
| T
|
||||
| {
|
||||
block?:
|
||||
| T
|
||||
| {
|
||||
relationField?: T;
|
||||
id?: T;
|
||||
blockName?: T;
|
||||
};
|
||||
};
|
||||
defaultAccessRelation?: T;
|
||||
chainedRelation?: T;
|
||||
maxDepthRelation?: T;
|
||||
|
||||
Reference in New Issue
Block a user