flask-mongoengine icon indicating copy to clipboard operation
flask-mongoengine copied to clipboard

New Field Type: EmbeddedDocumentListField

Open gordol opened this issue 9 years ago • 20 comments

Basically same as ListField but provides some additional query helpers.

Field docs here and query docs here.

gordol avatar Mar 15 '15 07:03 gordol

+1

AlmogCohen avatar Nov 02 '15 15:11 AlmogCohen

EmbeddedDocumentListField already exists in MongoEngine (see https://github.com/MongoEngine/mongoengine/blob/master/mongoengine/fields.py#L718). Or did I misunderstand the issue?

wojcikstefan avatar Dec 23 '16 03:12 wojcikstefan

@wojcikstefan Why did you close this? You are indeed misunderstanding I think...

I know EmbeddedDocumentListField exists in mongoengine already, I even linked to their documentation. The links are broken now, but here are the latest:

field docs: http://docs.mongoengine.org/apireference.html#mongoengine.fields.EmbeddedDocumentListField

query docs: http://docs.mongoengine.org/apireference.html#embedded-document-querying

EmbeddedDocumentListFields are NOT SUPPORTED by flask-mongoengine. That is why I opened this issue.

There is no WTF convertor defined for EmbeddedDocumentListFields. There are convertors for EmbeddedDocuments, and for ListFields, but that is not sufficient. EmbeddedDocumentListFields have additional functionality that is not the same as a ListField of EmbeddedDocument fields.

gordol avatar Dec 23 '16 03:12 gordol

There is no WTF convertor defined for EmbeddedDocumentListFields. There are convertors for EmbeddedDocuments, and for ListFields, but that is not sufficient. EmbeddedDocumentListFields have additional functionality that is not the same as a ListField of EmbeddedDocument fields.

Ah, thanks for clarifying. I didn't infer from the original description that you're talking about supporting this field via the WTF model form. That's definitely worth looking into. Would you like to give it a shot and send a PR?

wojcikstefan avatar Dec 23 '16 03:12 wojcikstefan

Indeed I would love to, but my time is limited until January. I can take a shot at it then, however.

gordol avatar Dec 23 '16 03:12 gordol

Great! I'll let you know if I get a chance to look at it earlier. If not, looking forward to Jan! :)

wojcikstefan avatar Dec 23 '16 06:12 wojcikstefan

Any chance to implement this?

xyzones avatar Aug 16 '17 08:08 xyzones

Nope, I've just been using db.ListField(db.EmbeddedDocumentField()) :(

I think maybe all we need to do is add a converter here?

https://github.com/MongoEngine/flask-mongoengine/blob/56caa8a8fc8f1b6b8e3d300ce0f38d2d1f906c1a/flask_mongoengine/wtf/orm.py#L161

https://github.com/MongoEngine/flask-mongoengine/blob/56caa8a8fc8f1b6b8e3d300ce0f38d2d1f906c1a/flask_mongoengine/wtf/orm.py#L192

Something that merges these two?

gordol avatar Aug 16 '17 18:08 gordol

Anything new for this issue?

ghost avatar Feb 01 '18 14:02 ghost

+1

devinclary avatar Feb 14 '18 05:02 devinclary

If nobody is working on this, I can take a stab at it in a week or so.

gordol avatar Feb 19 '18 05:02 gordol

@gordol +1 I have the same issue not for wtf forms I need it to use with Flask 1.02 and Flask Admin and is it possible ?

bekab95 avatar May 16 '18 09:05 bekab95

too busy myself, we've just worked around it in the meantime...

gordol avatar May 17 '18 00:05 gordol

@gordol is the EmbeddedDocumentListField much efficient than ListField ?

bekab95 avatar May 17 '18 12:05 bekab95

Its more about WTF-form realization in model_form, if I correct understand issue.

ghost avatar May 17 '18 12:05 ghost

https://github.com/flask-admin/flask-admin/issues/1644

it this related to mongoengine issue ?

bekab95 avatar May 23 '18 10:05 bekab95

any news ? @gordol

bekab95 avatar Apr 06 '20 19:04 bekab95

@insspb needed field..

bekab95 avatar Jun 07 '20 19:06 bekab95

+1

zloyded avatar Jul 08 '21 19:07 zloyded

we ended up just using a listfield of embedded docs if i recall correctly.

anything you can do with an EmbeddedDocumentList you can do with a List of EmbeddedDocuments and Aggregation Pipelines to get your agg/filter/map/reduce/etc. it's not exactly the same as far as mongoengine api is concerned, but it worked well enough for our use cases. actually, having the aggregation pipeline made it easier to do some other things later, but i digress.

anyway, that was ages ago (3-5 years), i don't have that code base around now, apologies.

gordol avatar Jul 12 '21 21:07 gordol