Create a new Document in an Appwrite Database Collection

Share this video with your friends

Send Tweet

Part of the appeal of our events site is not only being able to show cool events, but allowing others to submit their own events. But so far we’ve only worked with data that already exists in our database, how do we create data?

The Appwrite SDK gives us the ability to easily create a new Document by passing in our data. Additionally, the SDK provides helpers that make dealing with things like unique Document IDs easy. But part of the trick with creating new data, is we need a mechanism to input data, which is where we’ll see how we can read a form in React with Typed out data, so that we can pass it along formatted to Appwrite.

We’ll first learn how to create a new Document using the Appwrite SDK. This includes the ID helpers for generating a unique ID, formatting dates to the required format, and using our existing Types for that creation process. When passing along our Types, we’ll omit the ID which we’ll only get once the data exists in the first place. We’ll then see how we can dynamically grab data from a form, rather than hardcoding the input data, and open up access so that we have permission to create our new Document in Appwrite.

What You’ll Learn

  • Create a new Document in a Database Collection
  • Use the Appwrite ID helper to generate a unique ID
  • Format a date in the ISO format
  • Use the TypeScript Omit utility to use all properties of a Type except the ones omitted
  • Configure Create access for Documents
  • Read and set Types for data from a form

Resources