R
R
Raybul2022-02-25 14:45:50
Information Security
Raybul, 2022-02-25 14:45:50

How to create n number of keys in mongoose schema?

Hello everyone, how do I generate n number of keys in a mongoose schema?

const PostLikeSchema = new Schema({
    userId: {type: String},
    key1: {type: Array},
    key2: {type: Array},
    key3: {type: Array},
    key4: {type: Array},
    more key....
});

the bottom line is that there is a user who has posts in the posts there are likes, and I need that when adding a post, a key with the id of this post is added to the scheme with likes, and in the array by this key all who liked this post will lie.
How to implement? thank you in advance)

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
Shirshov Alexander, 2016-04-03
@Keanor

Read www.ozon.ru/context/detail/id/34377072 this book.

S
sim3x, 2016-04-03
@sim3x

owasp
CTF

M
Mike Booker, 2016-08-06
@MikeBooker

2f8cb114a78b4c98b385db2978be5c1b.jpg
https://habrahabr.ru/company/pentestit/blog/306336/

R
Raybul, 2022-02-25
@Raybul

had to add {strict: false} to the schema.

const PostLikeSchema = new Schema({
    userId: {type: String}
}, {strict: false});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question