Skip to content

Latest commit

 

History

History
37 lines (33 loc) · 890 Bytes

File metadata and controls

37 lines (33 loc) · 890 Bytes

Save queries to a table

All the mutative queries, ::insert, ::update and ::delete are not executed immediately, until saved. This gives the ability to ::revert the queries and a transactional feeling.

Note that after creating a new table, only on saving the data will be written to the system.

table.query()
  .then(rows =>
    console.log(rows)
    // []
  )
  .then(() => {
    table.insert(
      {column: 'column 1'},
      {column: 'column 2'}
    );
        
    return table.save()
  })
  .then(() => table.query())
  .then(rows =>
    console.log(rows)
    // [
    //   {
    //     $idbID: 1,
    //     column: 'column 1'
    //   },
    //   {
    //     $idbID: 2,
    //     column: 'column 2'
    //   }
    // ]
  );