-
Notifications
You must be signed in to change notification settings - Fork 1
/
delete.go
36 lines (29 loc) · 968 Bytes
/
delete.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
package numbersix
// DeleteValue removes the triple for the (subject, predicate, value) given. If
// none exist, then this does nothing.
func (d *DB) DeleteValue(subject, predicate string, value interface{}) error {
v, err := marshal(value)
if err != nil {
return err
}
_, err = d.db.Exec("DELETE FROM "+d.name+" WHERE subject = ? AND predicate = ? AND value = ?",
subject,
predicate,
v)
return err
}
// DeletePredicate removes all triples with the subject and predicate given. If
// none exist, then this does nothing.
func (d *DB) DeletePredicate(subject, predicate string) error {
_, err := d.db.Exec("DELETE FROM "+d.name+" WHERE subject = ? AND predicate = ?",
subject,
predicate)
return err
}
// DeleteSubject removes all triples for the subject given. If none exist, then
// this does nothing.
func (d *DB) DeleteSubject(subject string) error {
_, err := d.db.Exec("DELETE FROM "+d.name+" WHERE subject = ?",
subject)
return err
}