![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
koa-waterline-gowhich
Advanced tools
Middleware for your hose
npm install koa-waterline-gowhich
//see example.js
function* (){
var ctx = this;
var message = 'This is an example';
var commentCreated = yield ctx._waterline.collections.comments.create({message: message});
// You can yield to the CRUD waterline functions because they are written as promises.
console.log(commentCreated);
}
// OR
function* () {
var waterline = Waterline.init(injection);
var message = 'This is an example';
var commentCreated = yield waterline.collections.comments.create({message: message});
}
var connections= {
couch: {
adapter: "couch",
host: '127.0.0.1',
port: '5984',
username: '',
password: ''
},
mongo: {
adapter: "mongo",
host: 'localhost',
port: '27017',
user: '',
password: '',
database: 'waterline'
}
};
var adapters= {
couch: require('sails-couchdb-orm'),
mongo: require('sails-mongo')
};
var models = {
"comments": {
"adp": "couch",
"connection": "couch",
"properties": {
"archived": {
"type": "boolean",
"defaultValue": false
},
"message": {
"type": "string"
}
}
},
"history": {
"adp": "mongo",
"connection": "mongo",
"properties": {
"activity_id": {
"type": "number",
"enum": [
"unique"
]
}
}
}
};
var injection = {};
injection.methods = false;
injection.models = models;
injection.adapters = adapters;
injection.connections = connections
app.use(waterline(injection));
##Attributes Models - Required
- Models must have an adp, connection, and the properties attributes with the same design pattern in the example above.
Adapters - Required
- The adapters refer to the connection adapters; this is required and while seeming redundant it is required to run waterline
Connections - Required
- The connection attributes are the setting parameters for the data models to create the waterline.
Methods - Optional
- The methods attribute allows the injection of functions for virtual methods inside the model. An example of such an injection would something like this:
Methods Example:
var methods = {
history: function(){
//virtual methods specific to the history model
},
comments: function(){
//virtual methods specific to the comments model
}
};
MIT
FAQs
middleware for koa
The npm package koa-waterline-gowhich receives a total of 3 weekly downloads. As such, koa-waterline-gowhich popularity was classified as not popular.
We found that koa-waterline-gowhich demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.