javascript - rethinkDB:获取对象中的第一个键名
问题描述
我刚从 rethinkDB 查询语言开始,不明白如何选择第一个键(名称)。在这种情况下,我将成为对象笔记。
我用 Object.keys(t)[0]; 尝试只返回我的参数,我做错了什么?
{
id: "mission@0",
info:
"Tokyo",
**//how to get the value of content ?**
note: {
"note@032b8836-f647-4165-9ec9-fc22769f3ffa": {
content: "hello world",
context: "all",
glyphId: "glyph@default",
id: "note@032b8836-f647-4165-9ec9-fc22769f3ffa",
meta: {
context: null,
createdAt: 1624044683953,
id: "note@032b8836-f647-4165-9ec9-fc22769f3ffa",
links: null,
parentEntity: "mission@0b1cd61d-bb36-4cf8-8f3d-9cc9b14ff054",
references: { glyphId: "glyph" },
rootAggregateId: "mission@0b1cd61d-bb36-4cf8-8f3d-9cc9b14ff054",
rootAggregatePath: [
"private",
"notes",
"note@032b8836-f647-4165-9ec9-fc22769f3ffa",
],
status: "published",
summaries: {
description: "hello world",
glyph: "bookmark",
glyphColor: "base",
info: "hello world",
},
type: "note",
values: null,
version: 0,
},
},
}
function* extract(next) {
const q = r
.db("test")
.table("mission")
.getAll(true, { index: "recurrenceEnabled" })
.filter((mission) => mission("meta")("status").eq("published"))
.map((m) => {
let t = m("private")("notes");
let p = Object.keys(t)[0];
return {
note: t,
id: m("id"),
info: m("meta")("summaries")("info"),
};
});
return yield q.run(con, next);
}
感谢您的阅读!
解决方案
推荐阅读
- reporting-services - 带有 Switch 的 SSRS 2012 表达式未按预期工作
- django - 来自 django 教程的通用视图 UpdateView 不保存文件或图像
- github - 防止 GitHub PR 检查在没有人工干预的情况下运行
- email - 如何从 postfix 服务器禁用 postgrey?
- java - 使用 Java 中的 ghostscript 将 PDF 转换为多页 TIFF 文件
- go - golang中基于环境的数据库细节配置
- jquery - jquery期待点网核心升级到2.1后格式为“yyyy-MM-ddThh:mm”
- android - 在 Surface View 上调用 OnTouchEvent 时应用程序没有响应
- android - Android Studio v 3.1.4 中的小部件不会出现在设计模式中
- ajax - 通过ajax重新加载后,没有数据