我有一个 Coldfusion orm 应用程序,它有两个对象:
小部件.cfc
// Primary Key
property name="id" fieldtype="id" column="" generator="native";
// Properties
property name="col" type="string";
property name="created_at" type="date";
property name="kind" type="string";
property name="name" type="string";
property name="label" type="string";
property name="range" type="string";
property name="row" type="numeric";
property name="size" type="numeric";
property name="size_x" type="numeric";
property name="size_y" type="numeric";
property name="source" type="string" default="null";
property name="targets" type="numeric";
property name="update_interval" ormtype="int";
property name="update_at" type="date";
//Relationship
property name="dashboards" fieldtype="many-to-many"
linktable="DashboardWidgets"
type="array" cfc="dashboard"
cascade="all-delete-orphan" inverse="true" singularname="dashboard";
和dashboard.cfc
// Primary Key
property name="id" fieldtype="id" column="id" generator="native";
// Properties
property name="name" type="string";
property name="time" type="timestamp";
property name="layout" type="string";
property name="created_at" type="timestamp";
property name="updated_at" type="timestamp";
property name="locked" type="boolean";
//Relationships
property name="widgets" fieldtype="many-to-many"
linktable="DashboardWidgets" type="array" cfc="widget"
cascade="all-delete-orphan" singularname="widget";
我需要将 widget.cfc 的所有属性以及关系中定义的仪表板 ID 输出为 json。
所以我所拥有的是:
[{"id":5,"kind":"number",
"name":"dsfasdfa",
"size_x":1,
"size_y":1,
"source":"demo",
"update_interval":36000,
"dashboards":[{"id":3,"name":"Undefined name",
"time":"July, 24 2013 20:52:44 +0200",
"layout":"test",
"created_at":"July, 24 2013 20:52:44 +0200",
"updated_at":"July, 24 2013 20:52:44 +0200",
"locked":false,
"widgets":null}]
}]
我需要的是这样的:
[{"id":5,
"kind":"number",
"name":"dsfasdfa",
"size_x":1,
"size_y":1,
"source":"demo",
"update_interval":36000,
"dashboard_id":3
}]
我怎样才能做到这一点?我只需要仪表板的 id。