Giter Club home page Giter Club logo

mongoose-simple-random's People

Contributors

danielflippance avatar larryprice avatar laruche avatar marksyzm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

mongoose-simple-random's Issues

Depreciated

(node:1824) DeprecationWarning: collection.count is deprecated, and will be removed in a future version. Use collection.countDocuments or collection.estimatedDocumentCount instead

for code:

const items_random = await Item.findRandom({}, {}, {limit: 6}, function(err, docs) { return docs });

Please update. Thanks

The script will not select the last item in a collection.

I have a collection with 10 documents. This will only select one of the first 9 randomly. Or, 100 documents and it will only select one of the first 99.

  var start = Math.max(0, Math.floor((num-limit)*Math.random()));

might be written as

  var start = Math.max(0, Math.floor(((num-limit)+1)*Math.random()));

I didn't test.

Does `findRandom` return an array of sequential documents?

Would I be right in thinking that the "find many" function selects the first document randomly but the rest are simply those documents that directly follow it in mongo's sequence?

If so, it might be good to document that clearly. For some applications it would be an undesirable limitation. (For example pulling 5 random playing cards from an unshuffled deck would nearly always return a straight run!)

Consider unpublishing from NPM??

Given that built in $sample methods work much more efficiently, would you consider unpublishing, or maybe changing mongoose-simple-random to take advantage of such improvements?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.