Uses atcute to show how you can do upserts with atproto records
1# ATProto Upserts
2
3Example repo showing you how to upsert data to the PDS. This will have an attached leaflet I'll add later.
4
5Setup
6Make a copy of [.env.template](.env.template) and rename it to .env. Fill it out. Make sure to use your handle.
7
8```bash
9(p)npm install
10# Runs the tid example
11(p)npm run eample:tid
12# Runs the upsert example
13(p)npm run example:upsert
14```
15
16[./tid.js](./tid.js)
17Shows how you can create a TID from a datetime and convert it back
18```shell
19Its 1/15/2026, 9:57:18 PM or 1768535838046
20TID: 3mcj7faghtk2r
21Converted back: 1/15/2026, 9:57:18 PM or 1768535838046
22```
23
24[./upsert.js](./upsert.js)
25Shows how you can upsert data to the PDS using the TID from a known date to upsert.
26
27```shell
28You just finished a run. Uploading it to the PDS.
29Uploaded activity with rkey: 3mcj75qpg7c2r
30The PDS shows you went on a run at 2026-01-16T03:53:06.681Z.
31You just finished a walk. Uploading it to the PDS.
32Uploaded activity with rkey: 3mcj75qpg7c2r
33Uploaded activity with rkey: 3mcj75qspoc2r
34Since you did an upsert you should only have 2 records even tho you uploaded 3.
35You have 2 activities
36The PDS shows you went on a walk at 2026-01-16T03:53:06.789Z.
37The PDS shows you went on a run at 2026-01-16T03:53:06.681Z.
38```