Giter VIP home page Giter VIP logo

Comments (5)

AxeemHaider avatar AxeemHaider commented on August 26, 2024

Because you are doing it wrong. collection.save() method is supposed to use internally there is no save() method for public use. There is save method in instance level. There is collection.create() if you want to use.

Check documentation for Adding data
Also Adding data using Managaer

from fireo.

weiztech avatar weiztech commented on August 26, 2024

Hi @AxeemHaider ,
sorry, I have did typo and fix it above.
so on add new , I did use create method not save.

current issue tested with fireo==1.3.8

from fireo.

AxeemHaider avatar AxeemHaider commented on August 26, 2024

Why you want to save after creating document you don't need to save it.

The reason why it is not saving is as mention in error message itself.
ReferenceTypeError: Invalid reference type. Field "user" required value type "User", but got "ReferenceDocLoader

Because you set auto_load=False that's why when you try to save it error come up invalid type because it require User type. set auto_load=True so it load the User document or load it before saving it.

activity = UserActivity.collection.create(user=user)
activity.user = activity.user.get()
activity.save()

from fireo.

weiztech avatar weiztech commented on August 26, 2024

About the creating document and save it, this is just sample to reproduce the issue.

class ReferenceTestModel):
    Ref1 = ReferenceField(Amodel, auto_load=False)
    Ref2= ReferenceField(XModel, auto_load=False)
    Ref3= ReferenceField(YModel, auto_load=False)
    text = TextField(required=True)

hmm so, if I have above model instance and want to change only one field: text.
Did you mean, need to load all available reference fields for save method to work ?

from fireo.

AxeemHaider avatar AxeemHaider commented on August 26, 2024

You have to use update() method. Check Documentation for Update

from fireo.

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.