···20202121These types implement `Record`, an interface describing records.
22222323-You can get, list, create, update or delete them with functions.
2424-Each function starts with the action followed by the lexicon's name, e.g.,
2525-- `GetPublication` to get a publication;
2626-- `ListDocuments` to list documents;
2727-- `CreateDocument` to create a new document.
2828-2929-Currently, functions related to `Subscription` are not implemented.
2323+You can get, list, create, update or delete them with functions:
2424+- `GetRecord[*site.Publication]` to get a publication;
2525+- `ListRecords[*site.Document]` to list documents;
2626+- `CreateRecord[*site.Document]` to create a new document;
2727+- `UpdateRecord[*site.Subscription]` to update a subscription;
2828+- `DeleteRecord[*site.Publication]` to delete a publication.
30293130You can [verify](https://standard.site/docs/verification/) a publication with `Publication.Verify`.
3231
-34
document.go
···11package site
2233import (
44- "context"
54 "encoding/json"
65 "fmt"
76 "html/template"
···98 "time"
1091110 "github.com/bluesky-social/indigo/atproto/syntax"
1212- lexutil "github.com/bluesky-social/indigo/lex/util"
1311)
14121513const CollectionDocument = CollectionBase + ".document"
···103101 }
104102 *d = Document(v.t)
105103 return nil
106106-}
107107-108108-// GetDocument returns the [Document] in the repo associated with the rkey.
109109-// Automatically uses the latest CID.
110110-func GetDocument(ctx context.Context, client lexutil.LexClient, repo syntax.AtIdentifier, rkey syntax.RecordKey) (*Document, error) {
111111- return get[*Document](ctx, client, CollectionDocument, repo, rkey)
112112-}
113113-114114-// ListDocuments returns all the [Document]s stored in the repo and the cursor.
115115-//
116116-// See [MaxItemsPerList].
117117-func ListDocuments(ctx context.Context, client lexutil.LexClient, repo syntax.AtIdentifier, cursor string, reverse bool) ([]*Document, *string, error) {
118118- return listRecord[*Document](ctx, client, CollectionDocument, repo, cursor, reverse)
119119-}
120120-121121-// CreateDocument in a repo with the given rkey.
122122-// Always tries to validate the [Document] against the lexicon saved.
123123-//
124124-// Rkey can be nil.
125125-func CreateDocument(ctx context.Context, client lexutil.LexClient, repo syntax.AtIdentifier, rkey *syntax.RecordKey, doc *Document) (*Result, error) {
126126- return createRecord(ctx, client, CollectionDocument, repo, rkey, doc)
127127-}
128128-129129-// UpdateDocument in a repo with the given rkey.
130130-// Always tries to validate the [Document] against the lexicon saved.
131131-func UpdateDocument(ctx context.Context, client lexutil.LexClient, repo syntax.AtIdentifier, rkey syntax.RecordKey, doc *Document) (*Result, error) {
132132- return updateRecord(ctx, client, CollectionDocument, repo, rkey, doc)
133133-}
134134-135135-// DeleteDocument in a repo with the given rkey.
136136-func DeleteDocument(ctx context.Context, client lexutil.LexClient, repo syntax.AtIdentifier, rkey syntax.RecordKey) error {
137137- return deleteRecord(ctx, client, CollectionDocument, repo, rkey)
138104}
139105140106// GetDocumentVerificationTag returns the HTML link tag checked during the verification of the [Document].