This repository has been archived by the owner on Nov 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
database.js
75 lines (65 loc) · 1.51 KB
/
database.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
require('dotenv').config()
const { Deta } = require('deta')
const deta = Deta(process.env.DETA_PROJECT_KEY)
/*
* User
* Key: user_id
* Value: balance
*/
const user = deta.Base(process.env.DETA_BASE_PREFIX + 'User')
/*
* Spend
* Key: user_id
* Value: spend_amount
*/
const spend = deta.Base(process.env.DETA_BASE_PREFIX + 'Spend')
/*
* Donate
* Key: user_id
* Value: spend_amount
*/
const donate = deta.Base(process.env.DETA_BASE_PREFIX + 'Donate')
/*
* Address
* Key: user_id
* Value: address
*/
const address = deta.Base(process.env.DETA_BASE_PREFIX + 'Address')
/*
* Transaction
* Object: hash, status, user_id, balance, type
* status: PROCESSING or FINISHED
* type: DEPOSIT, WITHDRAW
*
* A deposit transaction will be processing after sent receive account block
* and be finished after balance updated.
*
* A withdraw transaction will be always finished.
*/
const transaction = deta.Base(process.env.DETA_BASE_PREFIX + 'Transaction')
/*
* Tip
* Column: amount, from, to, status_id, timestamp
* from, to: user id
*/
const tip = deta.Base(process.env.DETA_BASE_PREFIX + 'Tip')
/*
* System: system state like sinceIds for twitter api
*/
const system = deta.Base(process.env.DETA_BASE_PREFIX + 'System')
/*
* Antispam
* Key: user_id (twitter)
* Column: counter, timestamp
*/
const antispam = deta.Base(process.env.DETA_BASE_PREFIX + 'Antispam')
module.exports = {
user,
address,
transaction,
tip,
system,
spend,
donate,
antispam,
}