{"id":15605508,"url":"https://github.com/tswayne/hapi-water","last_synced_at":"2025-11-08T12:30:41.184Z","repository":{"id":51643465,"uuid":"118370455","full_name":"tswayne/hapi-water","owner":"tswayne","description":"Hapi waterline plugin","archived":false,"fork":false,"pushed_at":"2021-05-10T23:13:24.000Z","size":12,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-28T06:15:56.794Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tswayne.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-21T20:19:48.000Z","updated_at":"2020-01-05T19:41:41.000Z","dependencies_parsed_at":"2022-08-22T01:40:23.382Z","dependency_job_id":null,"html_url":"https://github.com/tswayne/hapi-water","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tswayne%2Fhapi-water","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tswayne%2Fhapi-water/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tswayne%2Fhapi-water/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tswayne%2Fhapi-water/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tswayne","download_url":"https://codeload.github.com/tswayne/hapi-water/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239558645,"owners_count":19658925,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T04:07:37.538Z","updated_at":"2025-11-08T12:30:41.130Z","avatar_url":"https://github.com/tswayne.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![npm](https://img.shields.io/npm/v/hapi-water.svg)](https://www.npmjs.com/package/hapi-water)\n\n# Hapi Water\nA hapi plugin for [waterline](https://github.com/balderdashy/waterline).  This plugin replicates waterline usage in sails by:\n* Allowing you to define waterline models exactly as in sails \n* Use any sails waterline adapter\n* Gives you access to your models anywhere in the request cycle through the request toolkit (`h.modelName._`)  \n\n## Usage\n\n```\n// Setup\nconst hapiWater = require('hapi-water')\n\nconst options = {\n adapter: require('sails-mysql'),\n adapterType: 'mysql',\n database: {\n   name: 'myDb',\n   user: 'user',\n   password: 'password',\n   host: 'localhost'\n },\n modelPath: path.join(__dirname, './models'),\n modelDefaults: {\n   datastore: 'default',\n   fetchRecordsOnCreate: true,\n   fetchRecordsOnUpdate: true,\n   primaryKey: 'id',\n   attributes: {\n     createdAt: { type: 'string', autoCreatedAt: true, },\n     updatedAt: { type: 'string', autoUpdatedAt: true, },\n     id: { type: 'number', autoMigrations: { autoIncrement: true } },\n   },\n }\n}\n\nawait server.register({ plugin: hapiWater, options }, { once: true })\n\n// Usage in handler\nconst pets = await h.models.pet.find()\n```\n\n#### Model definition\n```\n// ./model/Pet.js\nmodule.exports = {\n  identity: 'pet',\n  attributes: {\n    name: { type: 'string' },  \n  }\n}\n```\n\n## Options\n\n* adapter: Any of sail's [available adapters](https://next.sailsjs.com/documentation/concepts/extending-sails/adapters/available-adapters)\n* adapterType: The name of adapter, example: 'mysql', 'sails-disk', etc\n* database:\n  * name: The database name\n  * user: The database user\n  * password: The database password (optional)\n  * host: The database host\n  * port: The database port (optional)\n* modelPath: Path to the directory where your models are defined.\n* modelDefaults: Object. Any [model settings](https://sailsjs.com/documentation/concepts/models-and-orm/model-settings) that will apply to all models.   \n  * Great for setting default primaryKey, datastore, fetchRecordsOnUpdate, fetchRecordsOnCreate\n  * Will be overridden by specific model settings\n\n## Contributing\nPull requests or issues welcome!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftswayne%2Fhapi-water","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftswayne%2Fhapi-water","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftswayne%2Fhapi-water/lists"}