The collection was declared with exactly the fields it needs -- message, active, endsAt -- and PocketBase adds no created/updated unless asked. Both readers sort by -created, so both got 400 for the life of the feature: the app's NoticeService caught it and swallowed it, and the dashboard's own listing showed 'zatím žádné' however many notices existed. Writing worked throughout; nothing could read what was written. Additive and reversible. created is onCreate only; updated moves on every save, which costs nothing and is what a pull cursor wants.
36 lines
1.4 KiB
JavaScript
36 lines
1.4 KiB
JavaScript
/// <reference path="../pb_data/types.d.ts" />
|
|
|
|
// Give `notices` the `created` field everything already sorts by.
|
|
//
|
|
// The collection was declared with exactly the fields it needs -- message,
|
|
// active, endsAt -- and PocketBase does not add `created`/`updated` unless they
|
|
// are asked for. Both readers ask for `sort=-created`:
|
|
//
|
|
// - the app's NoticeService, which caught the resulting 400 and swallowed it,
|
|
// so a notice never appeared and nothing said why;
|
|
// - the status dashboard's own listing, which therefore always showed "zatím
|
|
// žádné" no matter how many notices existed.
|
|
//
|
|
// So the feature had never once worked end to end, and the failure was
|
|
// invisible from both ends. Writing worked; nothing could read what was written.
|
|
//
|
|
// `onCreate` only for `created`; `updated` moves on every save, which is what a
|
|
// pull cursor wants and costs nothing here.
|
|
migrate(
|
|
(app) => {
|
|
const c = app.findCollectionByNameOrId("notices");
|
|
c.fields.add(
|
|
new Field({ type: "autodate", name: "created", onCreate: true, onUpdate: false }),
|
|
);
|
|
c.fields.add(
|
|
new Field({ type: "autodate", name: "updated", onCreate: true, onUpdate: true }),
|
|
);
|
|
app.save(c);
|
|
},
|
|
(app) => {
|
|
const c = app.findCollectionByNameOrId("notices");
|
|
c.fields.removeByName("created");
|
|
c.fields.removeByName("updated");
|
|
app.save(c);
|
|
},
|
|
);
|