mirror of
https://github.com/trailbaseio/trailbase.git
synced 2026-01-15 06:10:36 -06:00
Breaking: nest records in output of RecordAPI.list to contain cursor now and potentially more in the future.
Also update all the client libraries to accept the new format.
This commit is contained in:
@@ -6,8 +6,8 @@
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"format": "prettier -w src",
|
||||
"read": "tsc && node dist/src/index.js",
|
||||
"fill": "tsc && node dist/src/fill.js",
|
||||
"read": "node --loader ts-node/esm src/index.js",
|
||||
"fill": "node --loader ts-node/esm src/fill.js",
|
||||
"check": "tsc --noEmit --skipLibCheck && eslint"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -16,6 +16,7 @@
|
||||
"eslint": "^9.18.0",
|
||||
"prettier": "^3.4.2",
|
||||
"quicktype": "^23.0.170",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.7.3",
|
||||
"typescript-eslint": "^8.20.0"
|
||||
},
|
||||
|
||||
@@ -8,18 +8,28 @@ const client = new Client("http://localhost:4000");
|
||||
await client.login("admin@localhost", "secret");
|
||||
const api = client.records("movies");
|
||||
|
||||
let movies = [];
|
||||
do {
|
||||
movies = await api.list<Movie>({
|
||||
// Start fresh: delete all existing movies.
|
||||
let cnt = 0;
|
||||
while (true) {
|
||||
const movies = await api.list<Movie>({
|
||||
pagination: {
|
||||
limit: 100,
|
||||
},
|
||||
});
|
||||
|
||||
for (const movie of movies) {
|
||||
const records = movies.records;
|
||||
const length = records.length;
|
||||
if (length === 0) {
|
||||
break;
|
||||
}
|
||||
cnt += length;
|
||||
|
||||
for (const movie of records) {
|
||||
await api.delete(movie.rank!);
|
||||
}
|
||||
} while (movies.length > 0);
|
||||
}
|
||||
|
||||
console.log(`Cleaned up ${cnt} movies`);
|
||||
|
||||
const file = await readFile("../data/Top_1000_IMDb_movies_New_version.csv");
|
||||
const records = parse(file, {
|
||||
@@ -41,3 +51,5 @@ for (const movie of records) {
|
||||
description: movie.description,
|
||||
});
|
||||
}
|
||||
|
||||
console.log(`Inserted ${records.length} movies`);
|
||||
|
||||
@@ -12,4 +12,4 @@ const m = await movies.list({
|
||||
filters: ["watch_time[lt]=120"],
|
||||
});
|
||||
|
||||
console.log(m);
|
||||
console.log(m.records);
|
||||
|
||||
5
examples/tutorial/traildepot/.gitignore
vendored
5
examples/tutorial/traildepot/.gitignore
vendored
@@ -3,3 +3,8 @@ backups/
|
||||
data/
|
||||
secrets/
|
||||
uploads/
|
||||
|
||||
!migrations/
|
||||
|
||||
trailbase.js
|
||||
trailbase.d.ts
|
||||
|
||||
Reference in New Issue
Block a user