Skip to content

Creating table with inserting default rows #362

Answered by ujjwalguptaofficial
afbora asked this question in Q&A
Discussion options

You must be logged in to vote

Creating a table and inserting data into table are two different process. So you need to write two query for it.

  1. Add table basically updating database schema
  2. Insert data into the new table

JsStore returns true when you create or update the db schema.

// initiate jsstore connection
var connection = new JsStore.Connection();

// step1 - create database schema
var tblProduct = {
    name: 'Product',
    columns: {
        // Here "Id" is name of column 
        Id:{ primaryKey: true, autoIncrement: true },
        ItemName:  { notNull: true, dataType: "string" },
        Price:  { notNull: true, dataType: "number" },
        Quantity : { notNull: true, dataType: "number" }
    }
};

var tb…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by afbora
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants