{"name":"sails-hook-orm","version":"4.0.2","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.6.4","chalk":"1.1.3","flaverr":"^1.8.0","parley":"^3.3.2","prompt":"1.2.1","sails-disk":"^2.0.0","waterline":"^0.15.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":"ce23c5e91f3728acc7d782b62d7a6257c36e1309","_id":"sails-hook-orm@4.0.2","_nodeVersion":"14.17.0","_npmVersion":"7.20.0","dist":{"integrity":"sha512-uNB1SW3thRyGo0KH0W+FTNMrKl/iGAayJedlMZmEsy3HbioI3sCiI0rDaL/gR4eWAoj3w2ZeUbl7NMpsuVvxoQ==","shasum":"3e621a55ccbb203f1e0353dedc7487040f64f97c","tarball":"http://registry-npm.ywwl.com/sails-hook-orm/download/sails-hook-orm-4.0.2.tgz","fileCount":37,"unpackedSize":212885,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCHPgVJYgRQudmFNkMiLia5HVdGd6A8nTDviQCORCd0jwIhAJzKAs9/PDW+SDfKTkWk2f4ZRVMvPEP+zj8Bdxdl+t87"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi8/enACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrHHQ//b+35p21e23JJzVl/yxzenhiecZ1NX9EEZUzQtvbs7Dg3wsCX\r\nvwl9BxQP7vN2LDUsSpFvtAVF8Rswab/8/Mi/dg+lvBf3yQ8Ufql8G+QIavSc\r\nvu4tsUyZ5rDFXDFZegFQRk68w50F1AiyUgGndhX08xJi8UbnZ9dqxwI6GVEk\r\neweY/Shxh0hPT6OmuxP72um1oUWHWmCNdU1eWIJFsm1lxVGNADw8zVoe7F4H\r\nEx6Xz8zfGOxozJB+O2WrtHKjGripvSr7CU9SIJZwvk4G88CcMVXBj3HrW3RH\r\nNmkAplutKuJQrIKx4AMLv49h+oWBX/FmKUIDuedcIgeRIDjHMnepSsAVpPxI\r\n6oObcfBz/FHm067UwGvhQPlJ3j4xHA7cuVHOU8x1fCudWp22m0WKM4CDLnR1\r\nXojVeG3fm8fY/n0RnizUiF1/8dWO0wIVWVgImyPW0UXRqwwmtlYjusSRhg+n\r\nfyzekr6fnGfW+cf8M6qGfeGBrDnLxxpy52XHJj5/Tz6WQQn0+dg56DKmmL6K\r\n6MGj30XzSicRdtGK4UfSkbuGF/XUrIJUwp4/V3AqdX6fJb7nBx89rxEoH6EH\r\n/5NF+PHNhxYEVmttTiDEi8vgkVcRJE86/8Ci5vJEiWoXRH/9eSxapIHflTK0\r\nU/fP8bWRmvNz13jzJRV3EXZVa6sLqArg5Bc=\r\n=Oat4\r\n-----END PGP SIGNATURE-----\r\n","size":49100,"noattachment":false,"key":"/sails-hook-orm/-/sails-hook-orm-4.0.2.tgz"},"_npmUser":{"name":"eashaw","email":"eashaw@sailsjs.com"},"directories":{},"maintainers":[{"name":"particlebanana","email":"particlebanana@gmail.com"},{"name":"rachaelshaw","email":"rachaelshaw@treeline.io"},{"name":"sgress454","email":"scottmgress@gmail.com"},{"name":"mikermcneil","email":"npm@sailsjs.com"},{"name":"eashaw","email":"eashaw@sailsjs.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sails-hook-orm_4.0.2_1660155815718_0.8585342643434377"},"_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":1660155815879,"_cnpm_publish_time":1660155815879,"dist-tags":{"for-sails-0.12":"1.0.9","latest":"4.0.3"}}