Google/Protobuf/Timestamp返回空对象
我有一个原始文件,应该返回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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论