You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
function nanoTest() {
nSQL('users') // "users" is our table name.
.model([ // Declare data model
{key:'id',type:'int'},
{key:'name',type:'string'},
{key:'age', type:'int'}
])
.connect() // Init the data store for usage. (only need to do this once)
.then(function(result) {
return nSQL().query('upsert', [
{id:1, name:"bill", age: 20},
{id:2, name:"tom", age: 30},
{id:3, name:"john", age: 33}
]).exec();
});
nSQL('users2') // "users" is our table name.
.model([ // Declare data model
{key:'id',type:'int'},
{key:'tel',type:'string'},
{key:'cell', type:'string'}
])
.connect() // Init the data store for usage. (only need to do this once)
.then(function(result2) {
return nSQL().query('upsert', [
{id:1, tel:"02-111-1111", cell: '010-1111-1111'},
{id:2, tel:"02-345-3456", cell: '010-1111-1112'},
{id:3, tel:"02-123-3456", cell: '010-1111-1112'}
]).exec();
});
// 데이터 조인
nSQL("users")
.query("select",["users2.id", "users.name","users.age","users2.tel","users2.cell"])
.where(["users.id",">",0])
.join({
type:"inner", // Supported join types are left, inner, right, cross and outer.
table: "users2",
where: ["users.id", "=", "users2.id"] // any valid WHERE statement works here
}).exec().then(function(rows) {console.log(rows);
});
}
But I saw a exception.
uncaught exception: nSQL: Database not connected, can't do a query!
I tested on firefox.
The text was updated successfully, but these errors were encountered:
The problem is towards the bottom, this bit of code:
// 데이터 조인nSQL("users").query("select",["users2.id","users.name","users.age","users2.tel","users2.cell"]).where(["users.id",">",0]).join({type:"inner",// Supported join types are left, inner, right, cross and outer.table: "users2",where: ["users.id","=","users2.id"]// any valid WHERE statement works here}).exec().then(function(rows){console.log(rows);
You can't call a query until you connect the database, the best option is just adding an onConnect callback around it.
nSQL().onConnected(()=>{// 데이터 조인nSQL("users").query("select",["users2.id","users.name","users.age","users2.tel","users2.cell"]).where(["users.id",">",0]).join({type:"inner",// Supported join types are left, inner, right, cross and outer.table: "users2",where: ["users.id","=","users2.id"]// any valid WHERE statement works here}).exec().then(function(rows){console.log(rows);});
Hi there,
function nanoTest() {
nSQL('users') // "users" is our table name.
.model([ // Declare data model
{key:'id',type:'int'},
{key:'name',type:'string'},
{key:'age', type:'int'}
])
.connect() // Init the data store for usage. (only need to do this once)
.then(function(result) {
return nSQL().query('upsert', [
{id:1, name:"bill", age: 20},
{id:2, name:"tom", age: 30},
{id:3, name:"john", age: 33}
]).exec();
});
});
}
But I saw a exception.
uncaught exception: nSQL: Database not connected, can't do a query!
I tested on firefox.
The text was updated successfully, but these errors were encountered: