@Bailey_Pearson sorry to bother you again with this, but this is the errors I get:
await comments.updateOne(
{ _id: c1.insertedId },
{
$set: {
title: "Lifecycle Updated",
},
}
);
Type of property 'author' circularly references itself in mapped type '{ [Key in keyof Post]: Post[Key] extends Post ? [Key] : Post extends Post[Key] ? [Key] : Post[Key] extends readonly (infer ArrayType)[] ? Post extends ArrayType ? [...] : ArrayType extends Post ? [...] : [...] : [...]; }'.ts(2615)
Type of property 'comments' circularly references itself in mapped type '{ [Key in keyof Post]: Post[Key] extends Post ? [Key] : Post extends Post[Key] ? [Key] : Post[Key] extends readonly (infer ArrayType)[] ? Post extends ArrayType ? [...] : ArrayType extends Post ? [...] : [...] : [...]; }'.ts(2615)
Type of property 'comments' circularly references itself in mapped type '{ [Key in keyof User]: User[Key] extends User ? [Key] : User extends User[Key] ? [Key] : User[Key] extends readonly (infer ArrayType)[] ? User extends ArrayType ? [...] : ArrayType extends User ? [...] : [...] : [...]; }'.ts(2615)
Type of property 'post' circularly references itself in mapped type '{ [Key in keyof Comment]: Comment[Key] extends Comment ? [Key] : Comment extends Comment[Key] ? [Key] : Comment[Key] extends readonly (infer ArrayType)[] ? Comment extends ArrayType ? [...] : ArrayType extends Comment ? [...] : [...] : [...]; }'.ts(2615)
Type of property 'posts' circularly references itself in mapped type '{ [Key in keyof User]: User[Key] extends User ? [Key] : User extends User[Key] ? [Key] : User[Key] extends readonly (infer ArrayType)[] ? User extends ArrayType ? [...] : ArrayType extends User ? [...] : [...] : [...]; }'.ts(2615)
Type of property 'posts' circularly references itself in mapped type '{ _id: ["_id"]; title: ["title"]; posts: ["posts", number, ...any[]]; }'.ts(2615)
Type of property 'tags' circularly references itself in mapped type '{ [Key in keyof Post]: Post[Key] extends Post ? [Key] : Post extends Post[Key] ? [Key] : Post[Key] extends readonly (infer ArrayType)[] ? Post extends ArrayType ? [...] : ArrayType extends Post ? [...] : [...] : [...]; }'.ts(2615)
Type of property 'user' circularly references itself in mapped type '{ [Key in keyof Comment]: Comment[Key] extends Comment ? [Key] : Comment extends Comment[Key] ? [Key] : Comment[Key] extends readonly (infer ArrayType)[] ? Comment extends ArrayType ? [...] : ArrayType extends Comment ? [...] : [...] : [...]; }'.ts(2615)
export class Post {
constructor(data: Partial<Post> = {}) {
Object.assign(this, data);
}
_id?: ObjectId;
title: string;
comments: Comment[] = [];
authorId: ObjectId | any;
author: User;
number?: string | number;
tags: Tag[] = [];
tagsIds: ObjectId[] = [];
}
export class Comment {
_id?: ObjectId;
title: string;
date: Date;
// virtual
titleAndDate: string;
// virtual
get titleWithUserId() {
return this.title + " " + this.userId;
}
userId: ObjectId;
user: User;
postId: ObjectId;
post: Post;
}
export class User {
constructor(data: Partial<User> = {}) {
Object.assign(this, data);
}
_id?: ObjectId;
name: string;
title?: string;
comments: Comment[] = [];
posts: Post[] = [];
}