2020-10-16 19:12:53 +02:00
|
|
|
package model
|
|
|
|
|
2020-11-09 13:19:03 +01:00
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"io"
|
|
|
|
)
|
|
|
|
|
2020-10-22 15:22:36 +02:00
|
|
|
// Block is the basic data unit.
|
2020-10-16 19:12:53 +02:00
|
|
|
type Block struct {
|
2021-01-12 03:53:08 +01:00
|
|
|
ID string `json:"id"`
|
|
|
|
ParentID string `json:"parentId"`
|
|
|
|
RootID string `json:"rootId"`
|
|
|
|
ModifiedBy string `json:"modifiedBy"`
|
|
|
|
Schema int64 `json:"schema"`
|
|
|
|
Type string `json:"type"`
|
|
|
|
Title string `json:"title"`
|
|
|
|
Fields map[string]interface{} `json:"fields"`
|
|
|
|
CreateAt int64 `json:"createAt"`
|
|
|
|
UpdateAt int64 `json:"updateAt"`
|
|
|
|
DeleteAt int64 `json:"deleteAt"`
|
2020-10-16 19:12:53 +02:00
|
|
|
}
|
2020-11-09 13:19:03 +01:00
|
|
|
|
2020-12-10 21:41:06 +01:00
|
|
|
// Archive is an import / export archive
|
|
|
|
type Archive struct {
|
|
|
|
Version int64 `json:"version"`
|
|
|
|
Date int64 `json:"date"`
|
|
|
|
Blocks []Block `json:"blocks"`
|
|
|
|
}
|
|
|
|
|
2020-11-09 13:19:03 +01:00
|
|
|
func BlocksFromJSON(data io.Reader) []Block {
|
|
|
|
var blocks []Block
|
|
|
|
json.NewDecoder(data).Decode(&blocks)
|
|
|
|
return blocks
|
|
|
|
}
|