The name of the field found by mongoose custom

1. Write some mini applications with node recently. Using mongoose. There is a small problem. Do not understand (may not understand the English document or do not understand).

for example:

    video.find({},(err, videos) => {
        videos.forEach(val => {
            val.videoId = val._id;
            delete val.id;
        })
    })

find a normal method. Or can you tell me where it is in the document? I really don"t understand how to do it.

Feb.28,2021

video.find ({},'- id',function (err,doc) {})
the second parameter is a string, add-do not return id, do not add-only return id, multiple fields
http://mongoosejs.com/docs/ap.


https://codeshelper.com/a/11.

I wonder if this article can solve the problem of the landlord.


video.aggregate (). Project ({videoId: "$_ id"}). Exec ();
so OK

Menu