-
Notifications
You must be signed in to change notification settings - Fork 2
/
database.go
54 lines (47 loc) · 1.06 KB
/
database.go
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
package gitquery
import (
"gopkg.in/sqle/sqle.v0/sql"
"gopkg.in/src-d/go-git.v4"
)
const (
// TODO 'references' is a reserved keyword into the parser
referencesTableName = "refs"
commitsTableName = "commits"
tagsTableName = "tags"
blobsTableName = "blobs"
treeEntriesTableName = "tree_entries"
objectsTableName = "objects"
)
type Database struct {
name string
cr sql.Table
tr sql.Table
rr sql.Table
ter sql.Table
br sql.Table
or sql.Table
}
func NewDatabase(name string, r *git.Repository) sql.Database {
return &Database{
name: name,
cr: newCommitsTable(r),
rr: newReferencesTable(r),
tr: newTagsTable(r),
br: newBlobsTable(r),
ter: newTreeEntriesTable(r),
or: newObjectsTable(r),
}
}
func (d *Database) Name() string {
return d.name
}
func (d *Database) Tables() map[string]sql.Table {
return map[string]sql.Table{
commitsTableName: d.cr,
tagsTableName: d.tr,
referencesTableName: d.rr,
blobsTableName: d.br,
treeEntriesTableName: d.ter,
objectsTableName: d.or,
}
}