-
Notifications
You must be signed in to change notification settings - Fork 7
/
seed_detail.js
34 lines (31 loc) · 1.06 KB
/
seed_detail.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
var SeedDetail = exports = module.exports = {};
var db = require("./connect");
var Seed = require("./seed");
SeedDetail.create = function (user_id, user_gid, callback) {
db.query('INSERT INTO seed_details (user_id,user_gid,server_seed,client_seed) VALUES (?,?,?,?);',
[user_id,
user_gid,
Seed.create_server_seed(),
Seed.create_client_seed()],
function (err, rows, fields) {
if (err) {
console.log(err);
throw err;
}
console.log(err,rows);
SeedDetail.find(rows.insertId, callback);
})
};
SeedDetail.find = function (id, callback) {
db.query('SELECT * FROM seed_details where id = ?', id, function (err, rows, fields) {
if (err) {
console.log(err);
callback(err,null);
} else if (rows.length == 0) {
console.log("No seed detail by the id:" + id);
callback(null,null);
} else
callback(null,rows[0]);
}
)
};