{"name":"sails-hook-orm","version":"3.0.1","description":"The ORM hook from Sails core.","main":"index.js","scripts":{"test":"npm run lint && npm run custom-tests && echo 'Done.'","custom-tests":"node ./node_modules/mocha/bin/mocha test -t 15000 && echo","lint":"node ./node_modules/eslint/bin/eslint . --max-warnings=0 && echo '✔  Your code looks good.'"},"repository":{"type":"git","url":"git+https://github.com/balderdashy/sails-hook-orm.git"},"keywords":["waterline","orm","sails","hook","sails-hook"],"author":{"name":"Mike McNeil"},"license":"MIT","bugs":{"url":"https://sailsjs.com/bugs"},"homepage":"https://sailsjs.com","dependencies":{"@sailshq/lodash":"^3.10.2","async":"2.0.1","chalk":"1.1.3","flaverr":"^1.8.0","parley":"^3.3.2","prompt":"0.2.14","sails-disk":"^2.0.0","waterline":"^0.14.0-0","waterline-utils":"^1.0.0"},"sails":{"isHook":true,"hookName":"orm"},"devDependencies":{"eslint":"4.11.0","mocha":"3.0.2","sails":"^1.0.0-5"},"gitHead":"86e431ec88aad828e4aaa0b9a9eea3b13bd405a7","_id":"sails-hook-orm@3.0.1","_nodeVersion":"12.6.0","_npmVersion":"6.10.1","dist":{"integrity":"sha512-PF/b3Rv0YN8dgkyBEQvtknOH2rPX2zi4t6RDFA7kN5hJ9amZiE7NfEOrT69me1N6XLcvIjCyIvQpmfBEjmIFKw==","shasum":"fe5fe58ab9fcc5b7d44ce4ac2c8c3891b3537917","tarball":"http://registry-npm.ywwl.com/sails-hook-orm/download/sails-hook-orm-3.0.1.tgz","fileCount":37,"unpackedSize":212850,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJezU0fCRA9TVsSAnZWagAAVtsP/3+SWS85EMRAwiuYfeov\nUU8AHGiIMddbVTkcabvWDYeJCJlW4tz6Y6KdKXdoxOaE1Edw+0N1bsUwVOfU\nOW4/78i1hcekX+Z6OJfefeMs6kKV2WWn89idZ1+PkhqxX6q+or+JvlFIq12J\nsE4tse2+Lma1x7ZNQovrI8mCB44vMwBdm9Wl2azzQ4l8TKHXdYqMwkL5yh8x\nqiBmwAwJj9NdpcMNOAh2cspOKxustWgreM6cuutpl3u/YysoUwnMZoT7YCbP\n+Y/Thwmg0aSY9MhnhcwG2bQsU0OaklnZWqFAEph/sKXraKP/AWwumcTzdKLR\naknqDUaM+icRKeHDaSmFHJgIH2HSKpeAHQ0HvGrlAlBNVILPa4+RQintmvgY\n/iw0c2zXImLuiZ6WvN+7EDUrLzydX2bo4+9qLzDCDCGYIzpYR5qojVouad04\niKBRLinRTpFwzog8YhMPhhOhFaGq+7NLlOkVLu/BBH+vM3q2fm4gLaNYVcrg\nHro9YJvWfoavXZ+lFimt0YqWXEWId0TE+TOmju3xTTDwNZ9TmC/hU/au6fYy\nPmybQwj/68YksmoA0V8GRgVhcPbkrFzWnAL+nYyLO/hI6hZ53EDGmRvoO2iX\nsa4+X7k+LBGEAPPlqH0DsDEbZNk0NbT4b1G9MkDP/6o7rSC7FTkQk7mBfclx\nm9eb\r\n=xjxz\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBFNnBYWt08Zlc0v5i0f8++BI3PrFOY/I/nFR38ANcTMAiEA0ShRHyKmlk7crqm/Gk8mNF6fLXSTGsm2UcpS9GzsAuI="}],"size":49637,"noattachment":false,"key":"/sails-hook-orm/-/sails-hook-orm-3.0.1.tgz"},"maintainers":[{"email":"npm@sailsjs.com","name":"mikermcneil"},{"email":"particlebanana@gmail.com","name":"particlebanana"},{"email":"rachaelshaw@treeline.io","name":"rachaelshaw"},{"email":"sgress454@treeline.io","name":"sgress454"}],"_npmUser":{"name":"mikermcneil","email":"npm@sailsjs.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sails-hook-orm_3.0.1_1590512926651_0.6952202133530938"},"_hasShrinkwrap":false,"readme":"# sails-hook-orm\n\nImplements support for Waterline ORM in Sails.\n\n> This is a core hook in the Sails.js framework.  You can override or disable it using your sailsrc file or environment variables.  See [Concepts > Configuration](http://sailsjs.com/docs/concepts/configuration) for more information.\n\n\n## Dependencies\n\nIn order for this hook to load, the following other hooks must have already finished loading:\n\n- moduleloader\n- userconfig\n\n\n## Dependents\n\nIf this hook is disabled, in order for Sails to load, the following other core hooks must also be disabled:\n\n- blueprints\n- pubsub\n\n\n## Purpose\n\nThis hook's responsibilities are:\n\n\n##### Load adapters\n\nWhen Sails loads, this hook calls out to `sails.modules.loadAdapters()` (exposed by the `moduleloader`), loading any custom adapters defined within the app.  It also loads adapters which are installed as dependencies of the app itself (i.e. in its `node_modules/` folder).  These adapters are used when instantiating Waterline.\n\n\n##### Load and hydrate models, then expose them as `sails.models.*`\nWhen Sails loads, this hook calls out to `sails.modules.loadModels()` (exposed by the `moduleloader`), loading model files from the app's models folder.\n\n##### Prompt about auto-migration\nSince instantiating Waterline currently has the effect of auto-migrating existing data (dependending on the `migrate` configuration), the orm hook shows a prompt before instantiating Waterline if no `migrate` setting is explicitly configured.\n\n\n##### Instantiate Waterline\nAs mentioned above, since all configuration, models, and adapters are loaded, this hook can safely instantiate Waterline.\n\n\n##### Expose hydrated models as `sails.models`\nIt then passes them to Waterline to turn them into Model instances with all the expected methods like `.create()`, and then exposes them as `sails.models`.  Conventionally this models folder is `api/models/`, but it can be configured in `sails.config.paths`.\n\n- Note that the set of hydrated models in the `sails.models` also includes Waterline models which were implicitly created as junctors (i.e. for any `collection` associations whose `via` does not point at a `model` association).\n- Also note that models are exposed on `sails.models` are keyed by their identities.  That is, if you have a model file `Wolf.js`, it will be available as `sails.models.wolf`.\n\n\n##### Expose global variable for each model\nIf enabled (`sails.config.globals.models` set to true), use the inferred `globalId` of each model to expose it as a global variable.\n\n\n\n## Implicit Defaults\nThis hook sets the following implicit default configuration on `sails.config`:\n\n\n| Property                                       | Type          | Default         |\n|------------------------------------------------|:-------------:|-----------------|\n| `sails.config.globals.models`                  | ((boolean))   | `true`          |\n| `sails.config.models.datastore`                | ((string))    | `default`   |\n| `sails.config.datastores.default.adapter`      | ((ref))    | `require('sails-disk')`    |\n\n\ni.e.\n\n```javascript\n{\n  globals: {\n    adapters: true,\n    models: true\n  },\n\n  // Default model properties\n  models: {\n\n    // This default datastore for the app will be used for\n    // each model unless otherwise specified.\n    datastore: 'default'\n  },\n\n\n  // Connections to data sources, web services, and external APIs.\n  // Can be attached to models and/or accessed directly.\n  datastores: {\n\n    // Built-in disk persistence\n    // (by default, creates the file: `.tmp/localDiskDb.db`)\n    default: {\n      adapter: 'sails-disk'\n    }\n  }\n}\n```\n\n\n## Events\n\n##### `hook:orm:loaded`\n\nEmitted when this hook has been automatically loaded by Sails core, and triggered the callback in its `initialize` function.\n\n\n##### `hook:orm:reload`\n\nThis event is no longer emitted by this hook.  This event will likely be replaced by making `.reload()` a public function.\n\n> This event is experimental and is likely to change in a future release.\n\n\n##### `hook:orm:reloaded`\n\nEmitted when a reload is complete.  This event will likely be replaced by expecting a callback in `.reload()`.\n\n> This event is experimental and is likely to change in a future release.\n\n\n\n\n## Methods\n\n#### sails.hooks.orm.reload()\n\nReload the ORM hook, reloading models and adapters from disk, and reinstantiating Waterline.\n\n- Note that **this does not automatically reload dependent hooks** (such as blueprints).\n- Also note that there is currently no callback.\n\n```javascript\nsails.hooks.orm.reload();\n```\n\n\n> ##### API: Private\n> - Please do not use this method in userland (i.e. in your app or even in a custom hook or other type of Sails plugin).\n> - Because it is a private API of a core hook, if you use this method in your code it may stop working or change without warning, at any time.\n> - If you would like to see a version of this method made public and its API stabilized, please open a [proposal](https://github.com/balderdashy/sails/blob/master/CONTRIBUTING.md#v-proposing-features-and-enhancements).\n\n\n\n\n#### sails.hooks.orm.teardown()\n\nCall the `teardown()` method for adapters which have one, and which were previously loaded by the ORM hook.\n\n```javascript\nsails.hooks.orm.teardown(cb);\n```\n\n\n###### Usage\n\n\n|     |          Argument           | Type                | Details\n| --- | --------------------------- | ------------------- | ----------------------------------------------------------------------------------\n| 1   |        **cb**               | ((function))        | Optional. Fires when the teardown process for the hook is complete.\n\n\n> ##### API: Private\n> - Please do not use this method in userland (i.e. in your app or even in a custom hook or other type of Sails plugin).\n> - Because it is a private API of a core hook, if you use this method in your code it may stop working or change without warning, at any time.\n> - If you would like to see a version of this method made public and its API stabilized, please open a [proposal](https://github.com/balderdashy/sails/blob/master/CONTRIBUTING.md#v-proposing-features-and-enhancements).\n\n\n\n## FAQ\n\n> If you have a question about this hook that isn't covered here, please feel free to send a PR adding it to this section (even if you don't have the answer, a core maintainer will merge your PR and add an answer as soon as possible)\n\n#### What is this?\n\nThis repo contains a hook, one of the building blocks Sails is made out of.\n\n#### What version of Sails is this for?\n\nThis hook is a dependency of Sails core as of Sails v0.12, in Sails v1, and beyond.\n\n\n#### Can I disable this hook?\n\nYes.  To disable this hook, merge the following JSON into your project's `.sailsrc` file:\n\n```json\n{\n  \"hooks\": {\n    \"orm\": false\n  }\n}\n```\n\n#### Can I override this hook to use a different ORM like Mongoose or Bookshelf instead of Waterline?\n\nYes.  To override this hook, define your replacement hook with `identity: orm` in your `.sailsrc` file or your app's `api/hooks/` directory.\n\n\n## Help\n\nIf you have further questions or are having trouble, click [here](http://sailsjs.com/support).\n\n\n## Bugs &nbsp; [![NPM version](https://badge.fury.io/js/sails-hook-orm.svg)](http://npmjs.com/package/sails-hook-orm)\n\nTo report a bug, [click here](http://sailsjs.com/bugs).\n\n\n## Contributing\n\nPlease observe the guidelines and conventions laid out in the [Sails project contribution guide](http://sailsjs.com/documentation/contributing) when opening issues or submitting pull requests.\n\n[![NPM](https://nodei.co/npm/sails-hook-orm.png?downloads=true)](http://npmjs.com/package/sails-hook-orm)\n\n\n## License\n\nThe [Sails framework](http://sailsjs.com) is free and open-source under the [MIT License](http://sailsjs.com/license).\n\n","publish_time":1590512926753,"_cnpm_publish_time":1590512926753,"dist-tags":{"for-sails-0.12":"1.0.9","latest":"4.0.3"}}