8000 GitHub - mongodb-utils/oid-sort-ids: sort a list of ObjectIDs or objects based on an array of ObjectIDs
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

mongodb-utils/oid-sort-ids

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ObjectID Sort IDs

NPM version Build status Test coverage Dependency Status License Downloads Gittip

Sort an array of objects or ObjectIDs based on another array of ObjectIDs. Because MongoDB can't do this themselves without some crazy ass hacks.

API

var sort = require('sort')

var arr = sort([
  ObjectId(2),
  ObjectId(10), {
    _id: ObjectId(3),
  }
], [
  ObjectId(1),
  ObjectId(2),
  ObjectId(3),
  ObjectId(4),
  ObjectId(5),
  ObjectId(6),
  ObjectId(7),
  ObjectId(8),
  ObjectId(9),
  ObjectId(10),
])

arr === [
  ObjectId(2), {
    _id: ObjectId(3),
  },
  ObjectId(10),
]

About

sort a list of ObjectIDs or objects based on an array of ObjectIDs

Resources

License

Stars

Watchers

Forks

Packages

No packages published
0