mirror of
https://github.com/Dvorinka/excalidraw-full.git
synced 2026-06-03 13:52:56 +00:00
2dd1421b6e
To get the most simple deployment of excalidraw, the binary should ship all components (webUI, socket.io, data storage).
32 lines
648 B
Go
32 lines
648 B
Go
package memory
|
|
|
|
import (
|
|
"context"
|
|
"excalidraw-complete/core"
|
|
"fmt"
|
|
|
|
"github.com/oklog/ulid/v2"
|
|
)
|
|
|
|
var savedDocuments = make(map[string]core.Document)
|
|
|
|
type documentStore struct {
|
|
}
|
|
|
|
func NewDocumentStore() core.DocumentStore {
|
|
return &documentStore{}
|
|
}
|
|
|
|
func (s *documentStore) FindID(ctx context.Context, id string) (*core.Document, error) {
|
|
if val, ok := savedDocuments[id]; ok {
|
|
return &val, nil
|
|
}
|
|
return nil, fmt.Errorf("document with id %s not found", id)
|
|
}
|
|
|
|
func (s *documentStore) Create(ctx context.Context, document *core.Document) (string, error) {
|
|
id := ulid.Make().String()
|
|
savedDocuments[id] = *document
|
|
return id, nil
|
|
}
|