Shows how to get repo export and walk it in TypeScript walktherepo.wisp.place
6
fork

Configure Feed

Select the types of activity you want to include in your feed.

docs docs docs

+5 -1
+5 -1
src/lib/RepoStats.svelte
··· 70 70 const car = fromStream(stream); 71 71 72 72 try { 73 + //This reads the repo as it is downloaded. which was very cool and I didn't know it would do that 73 74 for await (const entry of car) { 74 - 75 75 let checkForCollection = collections.find(c => c.collection === entry.collection); 76 76 if (!checkForCollection) { 77 77 collections.push({ collection: entry.collection, count: 1 }); ··· 105 105 try { 106 106 const rpc = new Client({ handler: simpleFetchHandler({ service: pdsUrl }) }); 107 107 startTimer(); 108 + //We can make a call to get a list of collections in the repo 108 109 let describeRepo = await rpc.get('com.atproto.repo.describeRepo', { 109 110 params: { 110 111 repo: did ··· 114 115 throw new Error(`HTTP error! status: ${describeRepo.status}`); 115 116 } 116 117 webCalls++; 118 + //We go through each collection and get a list of records in it 117 119 for (const collection of describeRepo.data.collections) { 118 120 let totalRecordsInCollection = 0; 119 121 currentCollection = collection; 122 + //Do the first call to get a cursor 120 123 const firstCollectionList = await rpc.get('com.atproto.repo.listRecords', { 121 124 params: { 122 125 collection, ··· 132 135 totalRecordsInCollection += firstCollectionList.data.records.length; 133 136 134 137 let cursor = firstCollectionList.data.cursor; 138 + //Walk the collection till the cursor is undefined meaning no more records 135 139 do { 136 140 const nextCollectionList = await rpc.get('com.atproto.repo.listRecords', { 137 141 params: {