Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upIssue with select left join from field columns #161
Closed
Labels
Comments
This comment has been minimized.
This comment has been minimized.
This has been resolved in |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nSQL().createDatabase({
id: "my-db",
mode: "TEMP", // pass in "PERM" to switch to persistent storage mode!
tables: [
{
name: "users",
model: {
// pk == primary key, ai == auto incriment,
"id:int": {pk: true, ai: true},
"name:string": {},
"age:int":{}
}
},
{
name: "users1",
model: {
// pk == primary key, ai == auto incriment,
"id:int": {pk: true, ai: true},
"name:string": {},
"age:int":{}
}
},
]
})
.then(function() {
// Add a record
nSQL("users1").query('upsert',{
name:"aaa", age: 10
}).exec();
})
.then(function(result) {
// select all rows
return nSQL()
.query('select',["users1.name AS aaa"])
.join({
type:"left",
with:{table:"users1"},
on:["users.name","=","users1.name"]
}).exec();
})
.then(function(result) {
var elem = document.createElement("pre");
document.body.appendChild(elem);
elem.innerHTML = JSON.stringify(result, null, 4)
})
result:
[
{
"aaa.0": "a",
"aaa.1": "a",
"aaa.2": "a"
}
]