mirror of
https://github.com/SecurityBrewery/catalyst.git
synced 2025-12-10 09:12:51 +01:00
Release catalyst
This commit is contained in:
25
database/busdb/keyed.go
Normal file
25
database/busdb/keyed.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package busdb
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
type Keyed struct {
|
||||
Key string
|
||||
Doc interface{}
|
||||
}
|
||||
|
||||
func (p Keyed) MarshalJSON() ([]byte, error) {
|
||||
b, err := json.Marshal(p.Doc)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
var m map[string]interface{}
|
||||
err = json.Unmarshal(b, &m)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
m["_key"] = p.Key
|
||||
|
||||
return json.Marshal(m)
|
||||
}
|
||||
Reference in New Issue
Block a user