L
L
Little Vasya2020-03-24 17:27:45
Node.js
Little Vasya, 2020-03-24 17:27:45

How to access child properties?

there is an object

{
            "comments": 0,
            "_id": "5e7a142125a650dfa132b984",
            "title": "dasdadasd",
            "description": "dasdasdadasdasdasd",
            "author": {
                "_id": "5e7a142125a650dfa132b985",
                "name": "Artem",
                "userId": "5e7a0bea506a9edca2abaf6c"
            }
        }


I need to access in this code userId:
1
Posts.find({ author: { userId: user._id } });

2
Posts.find({ 'author.userId': user._id });

But this implementation does not work

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rerurk, 2020-03-24
@Rerurk

user["id"]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question