MCPcopy Create free account
hub / github.com/bcspragu/logseq-sync / CreateGraph

Method CreateGraph

db/mem/mem.go:49–68  ·  view source on GitHub ↗
(_ context.Context, name string)

Source from the content-addressed store, hash-verified

47}
48
49func (d *DB) CreateGraph(_ context.Context, name string) (db.GraphID, db.Tx, error) {
50 for _, g := range d.graphs {
51 if name == g.graph.Name {
52 return "", 0, db.AlreadyExists("graph", "name")
53 }
54 }
55 id := db.GraphID(uuid.NewString())
56 tx := db.Tx(0)
57 d.graphs[id] = &graph{
58 graph: &db.Graph{
59 ID: id,
60 Name: name,
61 },
62 salts: []*db.GraphSalt{},
63 keys: []*db.GraphEncryptKey{},
64 metas: make(map[db.FileID][]*db.FileMeta),
65 tx: tx,
66 }
67 return id, tx, nil
68}
69
70func (d *DB) Graphs(_ context.Context) ([]*db.Graph, error) {
71 var out []*db.Graph

Callers

nothing calls this directly

Implementers 2

DBdb/mem/mem.go
DBdb/sqlite/sqlite.go

Calls 3

AlreadyExistsFunction · 0.92
GraphIDTypeAlias · 0.92
TxTypeAlias · 0.92

Tested by

no test coverage detected