Google/Protobuf/Timestamp返回空对象

发布于 2025-02-04 22:51:27 字数 837 浏览 3 评论 0原文

我有一个原始文件,应该返回create_at and Updated_at作为时间戳,然后将其保存在DB中,但是一旦我发送了一个请求,我都会收到一个空的对象,即使是两个db

proto文件中也保存了一个时间戳:

syntax = "proto3";

package user_package.v1;

import "google/protobuf/timestamp.proto";

message User {
    google.protobuf.Timestamp created_at = 1;
    google.protobuf.Timestamp updated_at = 2;
}

DB模式:( Mongo)

const schema = new mongoose.Schema({
  createdAt: {
    type: Date,
    default: Date.now,
  },
  updatedAt: {
    type: Date,
    default: Date.now,
  }
});

DB的响应:

[
  {
    createdAt: 2022-06-07T11:51:14.391Z,
    updatedAt: 2022-06-07T11:51:14.391Z,
    __v: 0
  }
]

致电RPC时收到的响应:

"users": [
        {
            "created_at": {},
            "updated_at": {},
        }
    ]

I have a proto file that is supposed to return created_at and updated_at as timestamps and they are saved that way in the DB, but once i send a request i get empty object for both even tho there is a timestamp saved in the DB

proto file:

syntax = "proto3";

package user_package.v1;

import "google/protobuf/timestamp.proto";

message User {
    google.protobuf.Timestamp created_at = 1;
    google.protobuf.Timestamp updated_at = 2;
}

DB schema: (mongo)

const schema = new mongoose.Schema({
  createdAt: {
    type: Date,
    default: Date.now,
  },
  updatedAt: {
    type: Date,
    default: Date.now,
  }
});

response from DB:

[
  {
    createdAt: 2022-06-07T11:51:14.391Z,
    updatedAt: 2022-06-07T11:51:14.391Z,
    __v: 0
  }
]

Response received when calling rpc:

"users": [
        {
            "created_at": {},
            "updated_at": {},
        }
    ]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文