-
Notifications
You must be signed in to change notification settings - Fork 14
/
app.js
36 lines (32 loc) · 1.09 KB
/
app.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
/**
* NOTE: This file is simply for testing this connector and will not
* be used or packaged with the actual connector when published.
*/
var Arrow = require('arrow')
var server = new Arrow()
var Post = Arrow.Model.extend('post', {
fields: {
title: { type: String },
content: { type: String }
},
disabledActions: ['findAndModify'],
connector: 'appc.mysql'
})
server.addModel(Post)
server.start(function (err) {
if (err) { server.logger.fatal(err) }
server.logger.info('server started on port', server.port)
// Create some posts programmatically.
var posts = [
{ title: 'A journey through time', content: 'take a journey' },
{ title: 'The Bible', content: 'In the beginning, God created the heavens and the earth.' }
]
Post.create(posts, function (err, posts) {
if (err) { return server.logger.error(err) }
server.logger.info('Created some posts:', [posts[0], posts[1]])
Post.find({ title: 'The Bible' }, function (err, results) {
if (err) { return server.logger.error(err) }
server.logger.info('Found The Bible:', results && results[0])
})
})
})