Comments (9)
Hey!
Thank you for the issue. This is a bug - fixed in the 1.7.1
. Please, update
from beanie.
I tried 1.7.1
and revision_id
has been removed from the output.
However, It is still in the schema, marked as hidden, and thus also appears in the example response
Is there anything we can do about that? Because now andybody who creates an api will have to explain to the user of the api what the purpose of revision_id.
from beanie.
Should be hidden there too now. Pls check 1.7.2
from beanie.
Yes, 1.7.2 totally resolves the visibility issue in output and schema. Thanks for your efforts.
More on a sidenote:
I noticed the field can still be 'used', so it is as the code calls it "hidden". So, when beanie is used in an API (say using FastAPI) the user of the api can still use the revision_id (although, if it is later no longer supported, not complain when it is removed as it is an undocumented api feature).
When the developer of the API wants to use the revision_id in the api, it has to be "un-hiden" (at this point, I would not know how, maybe by defining the field in my model?)
It might be completely against the philosophy of beanie (sorry I have not read the code yet), but it might be worth having these kind of features controlled from a config class of some sort like you see in other frameworks.
So the developer could write something like the code below to enable the revision_id:
class Note(Document):
title: str
text: Optional[str]
class Config:
use_revision_id = True
The idea being, by default "revision_id" is not used (not hidden, but really not used), but can be enabled using the config class.
This also gives you an opportunity to add new features in the future, which (by default) do not break an existing api generated by beanie (by adding of removing fields) and still allow the developer to adopt new features when needed / wanted.
from beanie.
Hey.
This make sense, but implementation could be tricky, as it is a pydantic field under the hood. I'll try to not use this field if the config is turned of soon.
Also, this feature is finally released. The doc about this could be found here: https://roman-right.github.io/beanie/tutorial/revision/
from beanie.
So this issue is a bit tricky. Its being caused by FastAPIs naive method of creating its document. I had to roll my own to get a functioning output. It was pretty easy to do I can see how portable to it is and if it is something I can port. The only issue becomes we would need to pin the pydantic version because its not code that is part of the API spec that needs to get replaced. Pydantic has a pretty slow release schedule so it is not that bad to do TBH.
from beanie.
This issue is stale because it has been open 30 days with no activity.
from beanie.
This issue was closed because it has been stalled for 14 days with no activity.
from beanie.
Not sure if it's the same issue but the inherited BaseModel.json()
model still includes the revision_id
.
from beanie.
Related Issues (20)
- Add support for $explain operator
- Inheritance and document initialization interaction should be clarified in the documentation
- Is possible to select or exclude links to fetch? HOT 1
- [BUG] Timezone-awareness broken in 1.18.0: TypeError when comparing offset-naive and offset-aware datetimes HOT 6
- [BUG] Impossible to subclass `Link` HOT 3
- @before_event w/set[BUG] HOT 2
- [BUG] Doc.save throw an error HOT 3
- Does not create collection via `init_beanie` function call when there are no user-defined index! HOT 3
- [BUG] Compatibility Break in Beanie v1.11.8 Causes Unnecessary Database Reads HOT 3
- [BUG] init_beanie() doesn't work properly sometimes HOT 11
- [BUG] Session not passed correctly in iterative data migrations HOT 1
- [BUG] Unable to use Or() in Doc.find_one() - unhashable type 'Eq' HOT 1
- [BUG] use "find" and [arg "projection"] query , occurs "TypeError" HOT 3
- Override insert and save methods HOT 3
- [BUG] Fetch_Links & Inheritance dont work if Link not on Parent Class HOT 3
- GridFs HOT 1
- Search operators without fields
- [BUG] Issue with `List[Link[Type]]` when `fetch_all_links` is called HOT 1
- [BUG] Migration does not run locally after upgrading to 1.19.1 HOT 3
- [BUG] Updates on Documents with "BackLink" do not behave as expected. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from beanie.