formattin~
This commit is contained in:
parent
f1c18e0b09
commit
c9c183fec0
@ -180,9 +180,9 @@ export default define(meta, paramDef, async (ps, me) => {
|
|||||||
const sortByDate = ps.order !== "relevancy";
|
const sortByDate = ps.order !== "relevancy";
|
||||||
|
|
||||||
type NoteResult = {
|
type NoteResult = {
|
||||||
id: string,
|
id: string;
|
||||||
createdAt: number
|
createdAt: number;
|
||||||
}
|
};
|
||||||
const extractedNotes: NoteResult[] = [];
|
const extractedNotes: NoteResult[] = [];
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
@ -221,8 +221,8 @@ export default define(meta, paramDef, async (ps, me) => {
|
|||||||
.map((key) => {
|
.map((key) => {
|
||||||
return {
|
return {
|
||||||
id: key.id,
|
id: key.id,
|
||||||
createdAt: key.createdAt
|
createdAt: key.createdAt,
|
||||||
}
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
extractedNotes.push(...res);
|
extractedNotes.push(...res);
|
||||||
@ -238,7 +238,7 @@ export default define(meta, paramDef, async (ps, me) => {
|
|||||||
// Fetch the notes from the database until we have enough to satisfy the limit
|
// Fetch the notes from the database until we have enough to satisfy the limit
|
||||||
start = 0;
|
start = 0;
|
||||||
const found = [];
|
const found = [];
|
||||||
const noteIDs = extractedNotes.map(note => note.id);
|
const noteIDs = extractedNotes.map((note) => note.id);
|
||||||
|
|
||||||
// Index the ID => index number into a map, so we can sort efficiently later
|
// Index the ID => index number into a map, so we can sort efficiently later
|
||||||
const idIndexMap = new Map(noteIDs.map((id, index) => [id, index]));
|
const idIndexMap = new Map(noteIDs.map((id, index) => [id, index]));
|
||||||
@ -246,20 +246,22 @@ export default define(meta, paramDef, async (ps, me) => {
|
|||||||
while (found.length < ps.limit && start < noteIDs.length) {
|
while (found.length < ps.limit && start < noteIDs.length) {
|
||||||
const chunk = noteIDs.slice(start, start + chunkSize);
|
const chunk = noteIDs.slice(start, start + chunkSize);
|
||||||
|
|
||||||
let query : FindManyOptions = sortByDate ? {
|
let query: FindManyOptions = sortByDate
|
||||||
|
? {
|
||||||
where: {
|
where: {
|
||||||
id: In(chunk),
|
id: In(chunk),
|
||||||
},
|
},
|
||||||
order: {
|
order: {
|
||||||
id: "DESC"
|
id: "DESC",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
} : {
|
: {
|
||||||
where: {
|
where: {
|
||||||
id: In(chunk),
|
id: In(chunk),
|
||||||
},
|
},
|
||||||
}
|
};
|
||||||
|
|
||||||
console.log(JSON.stringify(query))
|
console.log(JSON.stringify(query));
|
||||||
|
|
||||||
const notes: Note[] = await Notes.find(query);
|
const notes: Note[] = await Notes.find(query);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user