Giter VIP home page Giter VIP logo

Comments (5)

ostafen avatar ostafen commented on May 26, 2024 1

To achieve this, the FindAll() function should return an (interface{}, error). This means you should make additional check and conversion to get the actual type (slice or Document), also making the API not backward compatible.
However your idea is interesting and could be achieved by a separate FindFirst() function, returning a (*Document, error).
We could open a separate issue for this :=)

from clover.

ostafen avatar ostafen commented on May 26, 2024 1

@jsgm I added the FindFirst method with the last commit 59c3127
:=)

from clover.

ostafen avatar ostafen commented on May 26, 2024

Thank you for this suggestion. I think that I will add a Limit() method on the Query object :-)

from clover.

ostafen avatar ostafen commented on May 26, 2024

@gamedolphin, the last commit (5a5de33) adds a Limit(n int) method which allows to limit the output of FindAll() and Count().

You can give a look at the TestLimit function to see an example of usage. Before closing the issue, I wait for your feedback.

from clover.

jsgm avatar jsgm commented on May 26, 2024

What do you think about directly returning the document instead an array if Limit(n int) is 1?

from clover.

Related Issues (20)

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.