在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:ptariche/koa-waterline开源软件地址:https://github.com/ptariche/koa-waterline开源编程语言:JavaScript 100.0%开源软件介绍:koa-waterlineMiddleware for your hose
Usage
function* (){
let ctx = this;
let message = 'This is an example';
let 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);
}
function* () {
let waterline = yield Waterline.init(injection);
let message = 'This is an example';
let commentCreated = yield waterline.collections.comments.create({message: message});
}
Example let connections = {
couch: {
adapter: "couch",
host: '127.0.0.1',
port: '5984',
username: '',
password: ''
},
mongo: {
adapter: "mongo",
host: 'localhost',
port: '27017',
user: '',
password: '',
database: 'waterline'
},
cassandra: {
adapter: "cassandra",
host: '',
password: '',
contactPoints: ['127.0.0.1'],
keyspace: 'dev'
}
};
let adapters = {
couch: require('sails-couchdb-orm'),
mongo: require('sails-mongo'),
cassandra: require('sails-cassandra')
};
let models = {
"comments": {
"model": true,
"adp": "couch",
"connection": "couch",
"properties": {
"archived": {
"type": "boolean",
"defaultValue": false
},
"message": {
"type": "string"
}
}
},
"history": {
"model" : true,
"adp": "mongo",
"connection": "mongo",
"properties": {
"year": {
"type": "string"
}
}
},
"tweet": {
"adp": "cassandra",
"connection": "cassandra",
"index": ['tweet_body'],
"properties": {
"tweet_body": {
"type": "string"
}
}
},
"error": {
"model": false,
"properties": {
"erro": {
"type": "string"
}
}
}
};
let injection = {};
injection.methods = false;
injection.models = models;
injection.adapters = adapters;
injection.connections = connections;
app.use(waterline(injection)); ##Attributes Models - Required
Adapters - Required
Connections - Required
Methods - Optional
Methods Example:
Notes
Debug
AuthorsLicenseMIT |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论