Skip to content

Instantly share code, notes, and snippets.

@wuriyanto48
Created September 11, 2018 14:01
Show Gist options
  • Select an option

  • Save wuriyanto48/dd032aa8ec8945cb6d9882c9667ddf7a to your computer and use it in GitHub Desktop.

Select an option

Save wuriyanto48/dd032aa8ec8945cb6d9882c9667ddf7a to your computer and use it in GitHub Desktop.
SELECT s.id, s.sha1, f.name
FROM storage s
JOIN file f ON s.id = f.storage_id
WHERE s.count > 0
ORDER by id DESC, name ASC
OFFSET 1000 LIMIT 10
------------------------------
db.file_storage.aggregate([
{$match: {"count": {$gt: 0}}},
{$unwind: "$files"},
{$project: {_id: 1, sha1: 1, "name": "$files.name"}},
{$sort: {_id: -1, "name": 1}},
{$skip : 1000},
{$limit : 10},
])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment