🛠️ This documentation is still under construction
Node.js API
Update

Updating the database

A initialized database is ready to be updated. Before updating, a version source must be created.

Learn more about Version sources

For this example we'll use a very simple version source.

const version_source = {
  name: "example-db",
  version: [{
    _id: "1.0.0",
    createtable: {
      customers: {
        primary_key: "customer_id",
        customer_id: {
          type: "INT",
          a_i: True
        },
        name: {
          type: "VARCHAR",
          length: 100,
          unique: True
        },
        created: {
          type: "DATETIME"  
        }
      }
    },
    default_data: {
     customers: [
        {
          customer_id: 1,
          name: "John",
          created: "2023-10-31 02:12:52.000000"
        },
        {
          customer_id: 2,
          name: "Brian",
          created: "2022-02-21 11:42:19.000000"
        },
        {
          customer_id: 3,
          name: "Anouk",
          created: "2021-06-12 08:13:48.000000"
        }
      ]
    }
  }]
}

This will create the following table in your database:

customer_id 🔑namecreated
1John2023-10-31 02:12:52.000000
2Brian2022-02-21 11:42:19.000000
3Anouk2021-06-12 08:13:48.000000

Updating the table is as simple as just calling the update method. Make sure to supply the version source.

db.update(version_source=version_source)