-
Notifications
You must be signed in to change notification settings - Fork 0
/
seed.coffee
55 lines (49 loc) · 1.29 KB
/
seed.coffee
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
manifest = require './package.json'
mongoose = require 'mongoose'
mongoose.connect "mongodb://localhost/#{manifest.name}-dev"
Resource = require './models/Resource'
User = require './models/User'
user = new User
name:
first: 'John'
last: 'Doe'
email:"[email protected]"
user.save (err) ->
console.log err if err?
usr2 = new User
name:
first: 'Acme'
last: 'Company'
email:"[email protected]"
usr2.save (err) ->
console.log err if err?
console.log "Added ", user, usr2
res = new Resource
type: "offer"
name: "Sample Offer"
description: "This is a sample offer (in the future)"
start: new Date() + 300
end: new Date() + 36000
location:
lon: 0
lat: 0
tags: [ "offer", "shovel" ]
createdAt: new Date()
taker: null
res.save (err) ->
console.log err if err?
res2 = new Resource
type: "request"
name: "Sample request"
description: "This is a sample request"
start: new Date() - 300
end: new Date() + 36000
location:
lon: 0
lat: 0
tags: [ "request", "food" ]
sent: new Date()
taker: user
res2.save (err) ->
console.log err if err?
console.log "Added ", res, res2