Alex Dai Playground

[Sails] remove model collection association with blueprint

| Comments

example:

tasks model
{
  attributes: {
    title: {
      type: 'string'
    },
    responsiblePerson: {
      collection: 'user',
      via: 'tasks'
    }
  }
}
user model
{
  attributes: {
    title: {
      name: 'string'
    },
    tasks: {
      collection: 'tasks',
      via: 'responsiblePerson'
    }
  }
}
task data before
# GET /tasks/1/
{
  "responsiblePerson": [
    {
      "id": "2",
      "name": "alex"
    }
  ],
  "title": "just task title",
  "createdAt": "2016-03-30T01:53:03.941Z",
  "updatedAt": "2016-03-30T02:51:07.763Z",
  "id": "1"
}
task data after
# DELETE /tasks/1/responsiblePerson/2

{
  "responsiblePerson": [],
  "title": "just task title",
  "createdAt": "2016-03-30T01:53:03.941Z",
  "updatedAt": "2016-03-30T02:51:07.763Z",
  "id": "1"
}

http://sailsjs.org/documentation/reference/blueprint-api/remove-from

Comments

comments powered by Disqus