jsondb: Add Delete function
This allows database entries to be deleted. Related: RHEL-60120
This commit is contained in:
parent
fd7dc96d06
commit
5961b69caa
2 changed files with 43 additions and 0 deletions
|
|
@ -79,6 +79,14 @@ func (db *JSONDatabase) List() ([]string, error) {
|
|||
return names, nil
|
||||
}
|
||||
|
||||
// Delete will delete the file from the database
|
||||
func (db *JSONDatabase) Delete(name string) error {
|
||||
if len(name) == 0 {
|
||||
return fmt.Errorf("missing jsondb document name")
|
||||
}
|
||||
return os.Remove(filepath.Join(db.dir, name+".json"))
|
||||
}
|
||||
|
||||
// Writes `document` to `name`, overwriting a previous document if it exists.
|
||||
// `document` must be serializable to JSON.
|
||||
func (db *JSONDatabase) Write(name string, document interface{}) error {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue