为什么它不能在环回中加入?

时间:2016-11-02 06:05:47

标签: node.js mongodb rest loopbackjs strongloop

我继承了模型

body {
  width: 400px;
}
p {
  margin-top: 0;
  margin-bottom: 0.5em;
}
blockquote {
  background-color: antiquewhite;
  padding-top: 0.5em;
  padding-bottom: 0.5em;
  margin-top: 0;
  margin-bottom: 0.5em;
}
blockquote p:last-child {
  margin-bottom: 0;
}
blockquote p:first-child {
  margin-top: 0;
}

并创建钩子,用于保存用户的角色

<p>Some text before blockquotes</p>

<blockquote>
  <p><strong>1st blockquote</strong>
  </p>
  <p>1st paragraph. Foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo.</p>
  <p>2nd paragraph. Bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar.</p>
</blockquote>

<blockquote>
  <p><strong>2nd blockquote</strong>
  </p>
  <p>1st paragraph. Foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo.</p>
  <p>2nd paragraph. Bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar.</p>
</blockquote>

<p>Some text after blockquotes</p>

记录成功添加到db(mongo),但请求GET

{
  "name": "user",
  "plural": "users",
  "base": "User",
  "relations": {
    "roles": {
      "type": "hasMany",
      "model": "Role",
      "foreignKey": "principalId",
      "through": "RoleMapping"
    }
  },

记录未加入,为什么?

1 个答案:

答案 0 :(得分:-1)

您的查询字符串错误 包含过滤器应该是

/api/users?access_token={}&filter[include]=roles

include filter