209 похожих чатов

Всем привет! Прибиваю гвоздями Mongo к Nest. Создал схему для Person: import

{ Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import mongoose, { HydratedDocument } from 'mongoose';

export type PersonDocument = HydratedDocument<PersonSchemaModel>;

@Schema()
export class PersonSchemaModel {
@Prop({
type: String,
default: new mongoose.Types.ObjectId(),
unique: true,
required: true,
})
_id: string;

@Prop({ required: true })
name: string;

@Prop()
rs_url?: string;

@Prop({ type: [String], enum: Object.keys(personRoles) })
roles: string[];
}

export const PersonSchema = SchemaFactory.createForClass(PersonSchemaModel);


Но как только в модуле я пишу:

MongooseModule.forFeature([
{ name: PersonSchemaModel.name, schema: PersonSchemaModel },
]),

Оно валится с ошибкой The 2nd parameter to mongoose.model() should be a schema or a POJO
Error: The 2nd parameter to mongoose.model() should be a schema or a POJO.

Я не очень понимаю, где я накосячил, гуглёж мало чем помогает

5 ответов

4 просмотра

schema: PersonSchema а не PersonSchemaModel

Kenya-West-️ Автор вопроса
Alexander Bukhalo
schema: PersonSchema а не PersonSchemaModel

За помощь спс, но не помогло

Kenya-West ️
screenshot За помощь спс, но не помогло

ещё бы код где ты подключаешь схему

Kenya-West-️ Автор вопроса
Alexander Bukhalo
ещё бы код где ты подключаешь схему

Схема в отдельном модуле. Только что для изоляции перенес всё, что связано с Монгой, в отдельный модуль. Если просто гадить в корень, в AppModule, то ошибка всё равно та же. Код, где я что-то делаю со схемой, я закомментировал (см. скриншот 2), чтобы ограничить поиск ошибки. Ошибка возникает на скриншоте 1, когда я добавляю схему в MongooseModule.forFeature([])

Похожие вопросы

Обсуждают сегодня

Is Kadena onto something special? No one really knows. Good luck!
Bright Uncle Stephen EqualBet
40
isn't utxo commitements pretty close though if someone wanted to get it over the finish line? my understanding is that most of the ground work was already down by verde
Luke High - Rabbi Of Bcash High Rabbi Of Bcash
23
is the buyback program live and at what prices are the purchases fixed? excuse me for the bland PA question, sophisticated defi people keke
Imnothere
20
what is the current inflation of fxs?
Imnothere
12
Why in gods name do we need to connect our wallet to Discord to be eligible? Isn't holding the UOS token in a wallet enough?
Wingardium Cryptosa
16
My First Conversation with Roger Ver After reading Roger Ver's book, "Hijacking Bitcoin," I realized the importance of getting this information to people in their native lang...
Munnir
1
@samkazemian - couple questions: Update on frxBTC? - This would do well with the current influx of institutional investment entering the space Update on future veFXS streams...
Costi
16
I arrived here after a Chico Crypto show highlighted the project & the Team - the fact that the Team had a long history of successfully working with household names gave me e...
Banter is Bullish
5
Hi, I was reading this https://twitter.com/HouseofChimera/status/1778078991762780408 about Verasity and their likely choice of Tron as blockchain for their token for its low f...
Jordi
13
I've put a decent amount of work into the (just posted) algorithm for this proposal and would greatly appreciate any and all feedback. I would like to see unlocks become stan...
Luke SkywalkeI2
4
Карта сайта