let json = {
name:{
"john":{ street:"22 prospect place" , city:"stamford" , state:"CT" },
"jay":{ street:"111 northampton ave" , city:"amherst" , state:"MA" },
"joy":{ street:"1080 main street" , city:"boston" , state:"NY" },
"jer":{ street:"2022 plimpton ave" , city:"springfield" , state:"VT" },
}
}
let firstNameJ = json.SELECT[" * FROM name FILTER (state) WITH name.match(/^j/i) ORDERED"]
/*
name:{
"john":{ state:"CT" },
"jay":{ state:"MA" },
"joy":{ state:"NY" },
"jer":{ state:"VT" },
}
}
*/
let namesFromCT = json.SELECT[" * FROM name WITH state.match(/^CT$/) ORDERED"]
/*
name:{
"john":{ street:"22 prospect place" , city:"stamford" , state:"CT" },
}
*/
let MySortFunc = (a,b)=>{
return a[0]>b[0]
};
let namesSortByCity = json.SELECT[" * FROM name ORDERED_BY MySortFunc"]
/*
name:{
"jay":{ street:"111 northampton ave" , city:"amherst" , state:"MA" },
"joy":{ street:"1080 main street" , city:"boston" , state:"NY" },
"jer":{ street:"2022 plimpton ave" , city:"springfield" , state:"VT" },
"john":{ street:"22 prospect place" , city:"stamford" , state:"CT" },
}
*/
2 Likes
I like it, it would open a whole world. not to mention that since version 8 of mysql it is possible to use json.
you could even include subqueries, or use INSERT, UPDATE, DELETE. Although it would be almost like merging languages but it would make things much easier.
I could work with the different types of variables and using things like ISNULL ISNUMERIC is a powerful and complex idea and creates the MANGO possibility.
https://dev.mysql.com/doc/refman/8.0/en/json.html
there is a non-relational database that can be used in javascript without owning a server
https://pouchdb.com/
maybe we could get ideas from there.