{
  "_from": "loopback-counts-mixin",
  "_id": "loopback-counts-mixin@1.0.1",
  "_inBundle": false,
  "_integrity": "sha1-6nEqYVwijQiDodfjXQDfF+I3UQI=",
  "_location": "/loopback-counts-mixin",
  "_phantomChildren": {},
  "_requested": {
    "escapedName": "loopback-counts-mixin",
    "fetchSpec": "latest",
    "name": "loopback-counts-mixin",
    "raw": "loopback-counts-mixin",
    "rawSpec": "",
    "registry": true,
    "saveSpec": null,
    "type": "tag"
  },
  "_requiredBy": [
    "#USER",
    "/"
  ],
  "_resolved": "https://registry.npmjs.org/loopback-counts-mixin/-/loopback-counts-mixin-1.0.1.tgz",
  "_shasum": "ea712a615c228d0883a1d7e35d00df17e2375102",
  "_spec": "loopback-counts-mixin",
  "_where": "/var/www/html/recipes/api",
  "author": {
    "email": "exromany@gmail.com",
    "name": "exromany"
  },
  "bugs": {
    "url": "https://github.com/exromany/loopback-counts-mixin/issues"
  },
  "bundleDependencies": false,
  "dependencies": {},
  "deprecated": false,
  "description": "A mixin to enable get count of related models for a loopback Model.",
  "devDependencies": {
    "eslint": "^1.6.0"
  },
  "homepage": "https://github.com/exromany/loopback-counts-mixin#readme",
  "keywords": [
    "count",
    "loopback",
    "mixin",
    "relation",
    "strongloop"
  ],
  "license": "MIT",
  "main": "index.js",
  "name": "loopback-counts-mixin",
  "optionalDependencies": {},
  "readme": "# loopback-counts-mixin\nA mixin to enable get count of related models for a loopback Model.\n\n## INSTALL\n\n```\nnpm install --save loopback-counts-mixin\n```\n\nThere are 2 ways to enable mixin:\n\n### 1) server.js\n\nIn your server/server.js file add the following line before the boot(app, __dirname); line.\n\n```js\n...\nvar app = module.exports = loopback();\n...\n// Add Counts Mixin to loopback\nrequire('loopback-counts-mixin')(app);\n\nboot(app, __dirname, function(err) {\n  'use strict';\n  if (err) throw err;\n\n  // start the server if `$ node server.js`\n  if (require.main === module)\n    app.start();\n});\n```\n\n### 2) mixin sources\n\nAdd the mixins property to your server/model-config.json like the following:\n\n```json\n{\n  \"_meta\": {\n    \"sources\": [\n      \"loopback/common/models\",\n      \"loopback/server/models\",\n      \"../common/models\",\n      \"./models\"\n    ],\n    \"mixins\": [\n      \"loopback/common/mixins\",\n      \"loopback/server/mixins\",\n      \"../node_modules/loopback-counts-mixin\",\n      \"../common/mixins\",\n      \"./mixins\"\n    ]\n  }\n}\n```\n\n## CONFIG\n\nTo use with your Models add the `mixins` attribute to the definition object of your model config.\n\n```json\n{\n  \"name\": \"game\",\n  \"properties\": {\n    \"title\": \"string\"\n  },\n  \"relations\": {\n    \"players\": {\n      \"type\": \"hasMany\",\n      \"model\": \"player\"\n    }\n  },\n  \"mixins\": {\n    \"Counts\": true\n  }\n}\n```\n\n## USAGE\n\nIn fetching data with `counts` filter, will added field named like `relationnameCount`\n\n## EXAMPLE\n\n```\nhttp://0.0.0.0:3000/api/games?filter={\"counts\":\"players\"}\n```\n\nwill return list of games with field `playersCount`\n\n```json\n[\n  {\n    \"id\": 1,\n    \"title\": \"First game\",\n    \"playersCount\": 1\n  },\n  {\n    \"id\": 2,\n    \"title\": \"Last game\",\n    \"playersCount\": 42\n  }\n]\n```\n\n## LICENSE\n\nMIT\n\n",
  "readmeFilename": "README.md",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/exromany/loopback-counts-mixin.git"
  },
  "scripts": {
    "lint": "eslint ."
  },
  "version": "1.0.1"
}
