Files
Excalidraw/documents/memory/documents.go
T
patwie 2dd1421b6e Add webUI into binary
To get the most simple deployment of excalidraw, the binary should ship
all components (webUI, socket.io, data storage).
2024-03-29 09:55:57 +00:00

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
}