Git Product home page Git Product logo

Comments (1)

osnory avatar osnory commented on June 12, 2024 1

👍 Here; It seems that the problem is that follow_reference is not implemented when the result set has several records

This is inconsistent with mongoengine to_json method that works on all results sets;

See this code below

print("one supplier : " +  Supplier.objects.first().to_json())
print("all suppliers : " + Supplier.objects.all().to_json())

Returns

one supplier : {"id": "61090c626bb675ca4e3f844c", "name": "Nory Sup", "created": "2021-08-03T09:29:06.535254"}
all suppliers : [{"name": "Nory Sup", "id": "61090c626bb675ca4e3f844c"}, {"name": "new one1", "created": "2021-08-03T09:29:06.535000", "modified": "2021-08-03T09:29:06.593000", "id": "61090c62cf371f3947f64d3b"}]

With follow reference, this works

print("one supplier follow : " + Supplier.objects.first().to_json(follow_reference=True))
one supplier follow : {"id": "61090c626bb675ca4e3f844c", "name": "Nory Sup", "created": "2021-08-03T09:29:06.535254"}

But the results set response called below

print("all suppliers follow : " + Supplier.objects.all().to_json(follow_reference=True)) 

Fails with the following error

File "/Users/offer-nory/devel/projects/nory/Inventory-Service/src/scripts/playground.py", line 35, in do_stuff
    print("all suppliers follow : " + Supplier.objects.all().to_json(follow_reference=True))
  File "/Users/offer-nory/.virtualenvs/Inventory-Service/lib/python3.9/site-packages/mongoengine_goodjson/queryset.py", line 98, in to_json
    return json.dumps(lst, *args, **kwargs)
  File "/opt/homebrew/Cellar/[email protected]/3.9.4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/__init__.py", line 234, in dumps
    return cls(
  File "/Users/offer-nory/.virtualenvs/Inventory-Service/lib/python3.9/site-packages/mongoengine_goodjson/encoder.py", line 38, in __init__
    super(GoodJSONEncoder, self).__init__(*args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'follow_reference'

Will be good to get a response on this please !

from mongoengine-goodjson.

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.