...
1
2
3
4
5
6
7
8
9
10
11
12
13 package fs
14
15 import (
16 "context"
17 "errors"
18 "net/http"
19 "os"
20 "path/filepath"
21
22 "github.com/go-kivik/kivik/v4/driver"
23 "github.com/go-kivik/kivik/v4/x/fsdb/cdb"
24 "github.com/go-kivik/kivik/v4/x/fsdb/filesystem"
25 )
26
27 type db struct {
28 *client
29 dbPath, dbName string
30 fs filesystem.Filesystem
31 cdb *cdb.FS
32 }
33
34 var _ driver.DB = &db{}
35
36 var notYetImplemented = statusError{status: http.StatusNotImplemented, error: errors.New("kivik: not yet implemented in fs driver")}
37
38 func (d *db) path(parts ...string) string {
39 return filepath.Join(append([]string{d.dbPath}, parts...)...)
40 }
41
42 func (d *db) AllDocs(context.Context, driver.Options) (driver.Rows, error) {
43
44 return nil, notYetImplemented
45 }
46
47 func (d *db) Query(context.Context, string, string, driver.Options) (driver.Rows, error) {
48
49 return nil, notYetImplemented
50 }
51
52 func (d *db) Delete(context.Context, string, driver.Options) (newRev string, err error) {
53
54 return "", notYetImplemented
55 }
56
57 func (d *db) Stats(context.Context) (*driver.DBStats, error) {
58 _, err := d.fs.Stat(d.path())
59 if err != nil {
60 if errors.Is(err, os.ErrNotExist) {
61 return nil, &statusError{status: http.StatusNotFound, error: err}
62 }
63 return nil, err
64 }
65 return &driver.DBStats{
66 Name: d.dbName,
67 CompactRunning: false,
68 }, nil
69 }
70
71 func (d *db) CompactView(context.Context, string) error {
72
73 return notYetImplemented
74 }
75
76 func (d *db) ViewCleanup(context.Context) error {
77
78 return notYetImplemented
79 }
80
81 func (d *db) BulkDocs(context.Context, []interface{}) ([]driver.BulkResult, error) {
82
83 return nil, notYetImplemented
84 }
85
86 func (d *db) PutAttachment(context.Context, string, *driver.Attachment, driver.Options) (string, error) {
87
88 return "", notYetImplemented
89 }
90
91 func (d *db) GetAttachment(context.Context, string, string, driver.Options) (*driver.Attachment, error) {
92
93 return nil, notYetImplemented
94 }
95
96 func (d *db) DeleteAttachment(context.Context, string, string, driver.Options) (newRev string, err error) {
97
98 return "", notYetImplemented
99 }
100
101 func (d *db) Close() error {
102 return nil
103 }
104
View as plain text