V
V
vleypi2021-08-28 14:46:31
JavaScript
vleypi, 2021-08-28 14:46:31

How to implement an Array with objects in Schema Mongoose?

How to implement an Array with objects in Schema Mongoose so that there are no cast errors?
I tried a lot, the result was getting the desired one, but immediately after the result, a CastError error occurred. Mongoose Schema Mongoose

entry example . There is immediately more a question of what to enter here, and not what I entered and it didn’t work out for me : And when I tried my attempts, I got a casterror error I tried to do friends: [{ }],friends: [{ user: String }],friends: [{ _id: false,user:String}] , nothing helped, I don't know what to do anymore
612a20a0e32fd046607768.png


612a2106da439770706413.png


612a218ccf4bc559485813.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daniel Chistyakov, 2021-08-28
@danielchistyakov

friends: [
    {
      id: { type: String, required: true, unique: true },
    },
],

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question