This repository has been archived by the owner on Apr 10, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
example.js
98 lines (86 loc) · 2.16 KB
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
'use strict';
let koa = require('koa');
let waterline = require('./lib/koa-waterline.js');
const APP = koa();
let connections = {
mongo: {
adapter: 'mongo',
host: 'localhost',
port: '27017',
user: '',
password: '',
database: 'waterline'
}
};
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: {
lowercase: true,
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));
APP.use(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);
let year = '1976';
let createHistory = yield ctx._waterline.collections.history.create({year: year});
console.log(createHistory);
//
// let new_tweet = 'this is my example tweet!';
// let createTweet = yield ctx._waterline.collections.tweet.create({tweet_body: new_tweet});
// console.log(createTweet);
this.body = [createHistory];
});
APP.listen(1337);