atproto/repo
Generic com.atproto.repo.* record CRUD. Callers supply the collection NSID
and a decoder for each record row, so this module stays free of any lexicon.
Types
pub type CreatedRecord {
CreatedRecord(uri: String, cid: String)
}
Constructors
-
CreatedRecord(uri: String, cid: String)
Values
pub fn create_record(
client: xrpc.Client,
pds: String,
token: String,
did: String,
collection: String,
record: json.Json,
) -> Result(CreatedRecord, xrpc.XrpcError)
pub fn delete_record(
client: xrpc.Client,
pds: String,
token: String,
did: String,
collection: String,
rkey: String,
) -> Result(Nil, xrpc.XrpcError)
pub fn get_record(
client: xrpc.Client,
pds: String,
token: String,
did: String,
collection: String,
rkey: String,
value_decoder: decode.Decoder(a),
) -> Result(a, xrpc.XrpcError)
Fetch one record and decode its value with the supplied decoder.
pub fn get_record_envelope(
client: xrpc.Client,
pds: String,
token: String,
did: String,
collection: String,
rkey: String,
decoder: decode.Decoder(a),
) -> Result(a, xrpc.XrpcError)
Fetch one record, decoding the full envelope (uri/cid/value) with the supplied decoder, e.g. to build a strongRef to it.
pub fn list_records(
client: xrpc.Client,
pds: String,
token: String,
did: String,
collection: String,
row_decoder: decode.Decoder(a),
) -> Result(List(a), xrpc.XrpcError)
List every record in a collection, following the cursor across pages (the XRPC endpoint caps each page at 100). Returns the full set.
pub fn put_record(
client: xrpc.Client,
pds: String,
token: String,
did: String,
collection: String,
rkey: String,
record: json.Json,
) -> Result(CreatedRecord, xrpc.XrpcError)
Write a record at a known rkey (create or replace), keeping a stable URI.
pub fn upload_blob(
client: xrpc.Client,
pds: String,
token: String,
bytes: BitArray,
mime_type: String,
) -> Result(blob.Blob, xrpc.XrpcError)
Upload bytes to the authed repo. The returned ref must be embedded in a record before the PDS garbage-collects it.