Does db.notes.all() prioritize pinned notes over the specified sort order?

Bug report

When retrieving notes, I can sort them by createdAt or updatedAt in descending order. However, pinned notes always appear at the top, regardless of the specified sort order.

Is this the expected behavior?

Reference: Notes - Inkdrop API Reference

createdAt

let db = inkdrop.localDB;
let res = await db.notes.all({
  limit:5, sort: [{ createdAt: "desc" }] 
});

res.docs.forEach(d => {
  console.log(
    new Date(d.createdAt).toISOString(),
    d._id,
    d.pinned
  );
});
2026-06-16T09:19:51.703Z note:JuTSxRI7 true
2026-06-08T10:47:42.082Z note:uykWJtW_ true
2026-08-22T08:47:22.747Z note:rrf_PWGc undefined
2026-08-19T13:56:06.798Z note:x5AjOmnQ undefined
2026-08-01T07:20:52.839Z note:YxHZHuP8 undefined

udpatedAt

let db = inkdrop.localDB;
let res = await db.notes.all({
  limit:5, sort: [{ updatedAt: "desc" }] 
});

res.docs.forEach(d => {
  console.log(
    new Date(d.updatedAt).toISOString(),
    d._id,
    d.pinned
  );
});
2026-08-22T05:55:52.602Z note:uykWJtW_ true
2026-08-19T13:54:09.488Z note:JuTSxRI7 true
2026-08-22T14:36:04.909Z note:rrf_PWGc undefined
2026-08-22T08:32:44.697Z note:9PeEWUTV undefined
2026-08-22T08:30:33.612Z note:S4aoc83ZE false

Environment

  • Platform: macOS
  • Platform version: sequoia 15.7.9
  • App Version: 6.1.1

Hi @shimizu_tatsuya ,

Thanks for the question.
Right, the behavior has been changed since v6.0.0.
Pinned notes always come first regardless of the query args.
If you want to ignore pins, here is a workaround using FTS:

await inkdrop.localDB.notes.searchWithQuery([{
  type: 'field', field: 'pinned', id: ['true', 'false'] }
], { sort: [{ createdAt: 'desc' }], limit: 10 })

Hope it helps!

1 Like

It worked exactly as I expected. Thank you!

1 Like