GodotNuts / GodotFirebase

Implementations of Firebase for Godot using GDScript
MIT License
517 stars 74 forks source link

[BUG] Invalid get index 'fields' (on base: 'Dictionary'). #401

Closed lukethomas1 closed 1 month ago

lukethomas1 commented 1 month ago

(Godot 4) When running a simple var document = FirestoreDocument.new(), I get the above error Invalid get index 'fields' (on base: 'Dictionary').. I've traced the error to this line of code which was updated 3 days ago. The Godot Dictionary docs don't have any mention of a 'fields' variable, so it seems like this is a bug in the plugin rather than on my end, however I'd be happy to supply information or code snippets if necessary for debugging.

EDIT: I realized the Dictionary.fields syntax will get the 'fields' key out of the dictionary. However, despite that, using FirestoreDocument.new() will still fail because the default arg is an empty Dictionary. Is there an example of the proper usage for adding/updating a document using the FirestoreCollection object?

WolfgangSenff commented 1 month ago

You should not be using new on it. You have to get the document from Firestore the first time, or add it through a collection the first time. That will initialize it for you. Unfortunately, with the way Godot is setup, there's no way for me to restrict that. So check out the wiki and the upgrade guide and there's examples in it.