-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdbInit.js
41 lines (40 loc) · 1.19 KB
/
dbInit.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
/**
* Created by Gabriel on 2017-01-27.
*/
//DB 초기화를 위한 코드, 맨 처음 한번만 실행시켜주면 된다.
var orientDB = require("orientjs");
var dbServer = orientDB({ //connecting to orientdb
host: 'localhost',
port: 2424,
username: 'root',
password: 'ssh2159'
});
dbServer.drop('usersinfo');
var db = dbServer.create({ //userinfo라는 이름의 database를 만든다
name: "usersinfo",
type: "graph",
storage: "plocal"
}).then(function (db) {
db.class.create('User').then(function(user){ //사용자 정보 저장을 위한 User 클래스를 정의
user.property.create({
name: 'id',
type: 'String'
},{
name: 'password',
type: 'String'
},{
name: 'room',
type: 'String'
},{
name: 'ML_socket',
type: 'String'
},{
name: 'ML_login_status',
type: 'Boolean'
}).then(function (properties) {
console.log("Properties created");
db.close();
dbServer.close();
});
});
});