Giter VIP home page Giter VIP logo

Comments (13)

eldadfux avatar eldadfux commented on May 3, 2024 1

I might also be able to check if data parameter is a string and try to parse as a JSON to try an avoid this kind of an obvious confusion.

from appwrite.

doricci avatar doricci commented on May 3, 2024 1

For all the call about the collection, I have no issues, I find that the REST Client and the JS SDK are clear and doesn't need a lot of knowledge to be understood

from appwrite.

doricci avatar doricci commented on May 3, 2024 1

Thank you, now I'm able to add a document to the collection with the fix that you suggested, but the $collection has to be in the data object that is send.

I waiting the next release to remove this fix from my code!

I missed the documentation about the creation of the collection that you mentionned in #19 .

But thank you again for the quick answer and the great work!!

from appwrite.

eldadfux avatar eldadfux commented on May 3, 2024 1

Happy to help, I am already working on the fix, should be a one liner quick fix and probably be shipped in next version (might be out this week!).

from appwrite.

doricci avatar doricci commented on May 3, 2024 1

Ok thanks!
I'll wait the next release then.

from appwrite.

eldadfux avatar eldadfux commented on May 3, 2024

@doricci, first of all seems like it is a bug, because the server is printing an uncaught error - I will make sure to fix it by the next release.

Regarding this specific issue, you should pass the data param as a JSON object and not a string.

Make sure you have created a collection with matching structure to be able to pass the document creation validation.

If you have problems creating a new collection, we have a previous issue open about some parts missing in the docs. In the meantime we have a collection structure example here: #19

from appwrite.

doricci avatar doricci commented on May 3, 2024

@eldadfux thx for the quick answer!

I'm sending the data as a json object

{
  "data": {"test":"test"},
  "read": [],
  "write": [],
  "parentDocument": "",
  "parentProperty": "",
  "parentPropertyType": "assign"
}

and I get the current error now:

{
   "message":"Bad structure. Invalid document (#): Missing collection attribute $collection",
   "code":400,
   "file":"\/usr\/share\/nginx\/html\/app\/controllers\/database.php",
   "line":434,
   "trace":[
      {
         "function":"{closure}",
         "args":[
            "5d7e5234e6d9d",
            {
               "test":"test",
               "$permissions":{
                  "read":[
                     "*"
                  ],
                  "write":[
                     "*"
                  ]
               }
            },
            [
               "*"
            ],
            [
               "*"
            ],
            "",
            "",
            "assign"
         ]
      },
      {
         "file":"\/usr\/share\/nginx\/html\/vendor\/utopia-php\/framework\/src\/App.php",
         "line":401,
         "function":"call_user_func_array",
         "args":[
            {

            },
            {
               "collectionId":"5d7e5234e6d9d",
               "data":{
                  "test":"test"
               },
               "read":[
                  "*"
               ],
               "write":[
                  "*"
               ],
               "parentDocument":"",
               "parentProperty":"",
               "parentPropertyType":"assign"
            }
         ]
      },
      {
         "file":"\/usr\/share\/nginx\/html\/app\/app.php",
         "line":792,
         "function":"run",
         "class":"Utopia\\App",
         "type":"->",
         "args":[
            {

            },
            {

            }
         ]
      },
      {
         "file":"\/usr\/share\/nginx\/html\/public\/index.php",
         "line":27,
         "args":[
            "\/usr\/share\/nginx\/html\/app\/app.php"
         ],
         "function":"include"
      }
   ],
   "version":"latest"
}

from appwrite.

eldadfux avatar eldadfux commented on May 3, 2024

Umm, this is another thing that should be fixed by next version.

To fix it now just add '$collection' key to your data parameter JSON:

{
  "$collection": "YOUR_COLLECTION_ID_SAME_AS_IN_PATH",
  "data": {"test":"test"},
  "read": [],
  "write": [],
  "parentDocument": "",
  "parentProperty": "",
  "parentPropertyType": "assign"
}

from appwrite.

eldadfux avatar eldadfux commented on May 3, 2024

@doricci feel free to join us on gitter as well.

https://gitter.im/appwrite/community

from appwrite.

eldadfux avatar eldadfux commented on May 3, 2024

Committed a fix for the missing collection issue:
a5c3e97

from appwrite.

doricci avatar doricci commented on May 3, 2024

Hey, thanks for your time, now I'm able to login and register a new user without the api key, my issue was with angular, the session cookie wasn't set after the login ....

But now that I'm logged, the user is unable to create or read new collections.
[email protected] (role: member) missing scope (collections.read) and I have [email protected] (role: member) missing scope (collections.write) when I try to create a new collections.
The read and write of the same collection work when I set an API key.

Did I miss something in the documentation about how to create a collection? Or do I need to update the current user to add some permission?

from appwrite.

eldadfux avatar eldadfux commented on May 3, 2024

@doricci As mentioned before, this is a section of the documentation that is lacking and I am working on improving it + providing some real world examples.

Currently, Appwrite only allows creation of new collection using a Server SDK + API key + Relevant Scope ('collections.write'). This is meant to avoid users from abusing your collection creation endpoint.

If you want to allow all users to create new documents in a collection you created using a server SDK just create it with a public ("*") read permission.

from appwrite.

eldadfux avatar eldadfux commented on May 3, 2024

@doricci another thing I forgot to mention, in coming version we will add support for creating collections directly from the dashboard, which will make this process easier when getting started.

from appwrite.

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.