Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
231 views
in Technique[技术] by (71.8m points)

node.js - How to return the full object in shema mongoose

I try to dvp my first micro service by using grpc and shema mongoose as technologies. I try to get a specific object and send it to the client(as a front) But it returns only the empty fields. THis is my code:

  const comment=await Comment.find({comment_id:call.request.id}).exec(); 
     if(comment){
      console.log(comment);
      callback(null,{comment});
     }else {
      callback({
          code: grpc.status.NOT_FOUND,
          details: "Not found the comment"
      })
    }

what it returns when I run the server is:

[
  {
    interesting_comment: [],
    children: [],
    _id: 600fe05c0421114ab935d75f,
    comment_id: '2',
    author_id: '2',
    content: 'hello toto',
    creation_date: 2021-01-26T09:26:52.141Z,
    updated_content_list: [],
    __v: 0
  }
]

and what I get in the client is:

 {
  comment: { interesting_comment: [], updated_content_list: [], children: [] }
}
question from:https://stackoverflow.com/questions/65920267/how-to-return-the-full-object-in-shema-mongoose

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...