Adamite
  • Initial page
  • Server
    • Introduction
    • Database
      • Configuration
      • Using different adapters
        • Memory Adapter
      • Securing your data
        • Securing read operations
    • Functions
      • Invokable Functions
      • Runtime Functions
      • Scheduled Functions
  • SDK
    • Introduction
    • Database
      • Introduction
      • Read a document
      • Read multiple documents
      • Subscribe to changes
      • Create a new document
      • Update an existing document
      • Delete a document
    • Authentication
      • Create a user
      • Log in and log out
      • Get the logged in user
    • Functions
      • Invoke a function
Powered by GitBook
On this page

Was this helpful?

  1. SDK
  2. Database

Update an existing document

To update an existing document, you'll need a reference to it. You can directly reference a document by its ID, or you can access the ref property on a snapshot of the document.

const ref = adamite()
  .database()
  .collection("projects")
  .doc("documentId")
const projects = 
  await adamite()
    .database()
    .collection("projects")
    .get();
    
const ref = projects.docs[0].ref;

Once you have a reference to the document, you can update its data using the update function.

await ref.update({
  name: "Some other name"
});
PreviousCreate a new documentNextDelete a document

Last updated 5 years ago

Was this helpful?