-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnamespace.go
44 lines (35 loc) · 1.13 KB
/
namespace.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
/*
* Copyright 2025 Hypermode Inc.
* Licensed under the terms of the Apache License, Version 2.0
* See the LICENSE file that accompanied this code for further details.
*
* SPDX-FileCopyrightText: 2025 Hypermode Inc. <[email protected]>
* SPDX-License-Identifier: Apache-2.0
*/
package modusdb
import (
"context"
"github.com/dgraph-io/dgo/v240/protos/api"
)
// Namespace is one of the namespaces in modusDB.
type Namespace struct {
id uint64
engine *Engine
}
func (ns *Namespace) ID() uint64 {
return ns.id
}
// DropData drops all the data in the modusDB instance.
func (ns *Namespace) DropData(ctx context.Context) error {
return ns.engine.dropData(ctx, ns)
}
func (ns *Namespace) AlterSchema(ctx context.Context, sch string) error {
return ns.engine.alterSchema(ctx, ns, sch)
}
func (ns *Namespace) Mutate(ctx context.Context, ms []*api.Mutation) (map[string]uint64, error) {
return ns.engine.mutate(ctx, ns, ms)
}
// Query performs query or mutation or upsert on the given modusDB instance.
func (ns *Namespace) Query(ctx context.Context, query string) (*api.Response, error) {
return ns.engine.query(ctx, ns, query)
}