Git Product home page Git Product logo

Comments (5)

art049 avatar art049 commented on May 20, 2024 5

It's not there yet but it's in the plans :)

from odmantic.

art049 avatar art049 commented on May 20, 2024

Yes, the beginning of an implementation has been done in #1 .
But in the meantime, after some thoughts I ended up thinking that it would be better to use mongo db views to that end.
The usage with odmantic would be something like this:

class Rectangle(Model):
    length: int
    width: int

LengthView = createView(Rectangle, (Rectangle.length,))
# LengthView is a View object derived from pydantic; containing only the length field
rects = await engine.find(LengthView, Rectangle.width > 10)

On top of this, since we are using mongodb view, it would be as well possible to do something like this:

class RectangleAreaView(View, model=Rectangle):
    area = Rectangle.length * Rectangle.width

This would create a View containing a field computed (db side) from some other of its fields.

from odmantic.

skyox avatar skyox commented on May 20, 2024

Thank you so much

from odmantic.

amr3k avatar amr3k commented on May 20, 2024

Sorry, I don't get it!! where is the createView function? how do I use it?

from odmantic.

Azrael-git avatar Azrael-git commented on May 20, 2024

Hello, any updates about this issue? This functionality is very promising I think

from odmantic.

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.