问题描述
我有以下架构:-
用户是主要模式,在“跟随”下是数组之一。在“跟随”模式中,“用户”是“引用”到“用户”模式。可以引用相同的模式吗?
请阅读我的查询评论...
const FollowersSchema = new mongoose.Schema(
{
user: {
type: mongoose.Schema.Types.ObjectId,ref: 'User',// Is it possible to use ref in the same Schema? Cause 'UserSchema as User' is the current parent Schema
},},{
timestamps: true,}
);
const FollowingSchema = new mongoose.Schema(
{
user: {
type: mongoose.Schema.Types.ObjectId,}
);
const UserSchema = new mongoose.Schema(
{
full_name: {
type: String,default: '',dp: {
type: String,cover: {
type: String,view: {
type: Number,default: 0,email: {
type: String,bio: {
type: String,relationship: {
type: String,gender: {
type: String,social: [SocialSchema],education: [EduSchema],following: [FollowingSchema],followers: [FollowersSchema],}
);
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)