I am trying to query a JSON object in order to determine a username. However, when I run the SQLike i have 3996 objects returned, none of which matching the correct parameters that I have asked to be returned. Would anyone be able to point out where I have gone wrong and as to why I am receiving 3996 returned objects and further, how can I strip it out to only return a username?
user.json
[
{
"id":1,
"fName": "Sam",
"lName": "Street",
"username": "sam",
"password": "123"
},
{
"id":2,
"fName": "Matt",
"lName": "Mantle",
"username": "matt",
"password": "123"
},
{
"id":3,
"fName": "Dev",
"lName": "Mode",
"username": "dev",
"password": "123"
}
]
The javascript that I call on a submit of a form
$("#login_form").submit(function (e) {
// prevent default action
e.preventDefault();
var form = $(this);
var username = form.find("#username").val();
var password = form.find("#password").val();
// need to pass this as generic function when finished
var userData = $.ajax({
async: false,
url: 'user.json',
type: "GET",
dataType: "json",
success: function (data) {
console.log(data);
}
});
var sel = SQLike.q(
{
Select: ['*'],
From: userData,
Where: function () { return this.userData = username }
}
)
console.log(sel);
});