Closed NJseo closed 6 years ago
So here is what I figured out. When I get an item to check if its in the database, on the initial, it returns results as a single object. After one item gets put into the database, it returns as an object inside of an array. I think this is a mistake. It should always return as an object in an array.
Lets first talk about this -
Is there a simple way to increment a filed or do I have to do a get than an update?
You can use column option AutoIncrement. or is there something else you want ?
Seems like autoincrement would work out great.
Oh, wait. This is not an auto incrementing field, say like an id. Its more like sql's 'hitsField' = 'hitsField' + 1
yes, so do you want anything else ?
Basically autoincrement means - the field which is marked autoincrement will be incremented automatically, you don't need to suppy value for that field.
Yeah, the url to that. Additionally, that update item function you provided me has been troublesome. I am passing it a json object and putting that to Set.
So it would be:
Set: [jsonValues], OnSuccess: function(rowsUpdated) { alert("updated fields"); },
Where the JSON object is: {id: "8787890780978907909", url: "https://www.smartychat.co", refferer: "https://www.google.com", bID: "thisID_780978907909", otherID: "780978907909", …}
Anyhow I keep getting back this message and its been troubling me for a good portion of the day.
TypeError: Cannot read property '_columns' of undefined at Instance.Base.getColumnInfo (jsstore.js:1291) at Instance.Base._this.goToWhereLogic (jsstore.js:1249) at Instance.execute (jsstore.js:4250) at Main.update (jsstore.js:1719) at Main.executeLogic (jsstore.js:1657) at Main.checkConnectionAndExecuteLogic (jsstore.js:1609) at self.onmessage (jsstore.js:5369)
I think - you are doing it wrong.
First Set does not take an array, it takes only object. So you specify only that field in object, which you want to update.
Please have a look at docs once - http://jsstore.net/tutorial/update
Thanks
Do one thing - write sql query and try to convert in jsstore equivalent. And run that jsstore code. If that does not worked send me the sql query - I will give you equivalent query. That way you will be able to understand.
Thanks
Thankyou, I appreciate it. You are right, its easier to think sql first, the conversion second.
"INSERT INTO t1 (a,b,c) VALUES (1,2,3) ON DUPLICATE KEY UPDATE c=c+1";
INSERT INTO t1 (a,b,c) VALUES (1,2,3) ON DUPLICATE KEY UPDATE c=c+1
Do you want me to write jsstore query for this ?
Can we close this issue if all good ?
Yes, thank you.
Is there a simple way to increment a filed or do I have to do a get than an update?