Giter Club home page Giter Club logo

Comments (3)

rcdmk avatar rcdmk commented on June 12, 2024

Hi.
Do you mean "update a database record" when you say "Update the record"?

This class only provides an easy way to load records from a database into the structure and doesn't create a link between them. If you update a database record and want it to reflect in your JSON structure, you will have to load the recordset again in the object.

rs.open "select someField from table where someCondition = true"
JSON.LoadFirstRecord(rs)
jsonStr = JSON.Serialize() ' { "someField": "someValue" }

conn.execute "update table set someField = 'someOtherValue' where someCondition = true"
jsonStr = JSON.Serialize() ' { "someField": "someValue" } - no change

rs.Requery() ' re-run the database query
jsonStr = JSON.Serialize() ' { "someField": "someValue" } - still no change

JSON.LoadFirstRecord(rs)
jsonStr = JSON.Serialize() ' { "someField": "someOtherValue" } - updated

from aspjson.

vr2xiq avatar vr2xiq commented on June 12, 2024

Thx for you reply a
But why no change right after update SQL?
and why no change after Requery?
Thx

from aspjson.

rcdmk avatar rcdmk commented on June 12, 2024

Hi. Thank you for the suggestion.

I don't intend to make this sync because it's not the responsibility of this class.

If I link this to the recordset it will be more coupled and more issues can arise from this that people benefit from it, since the recordset will have to remain opened.

Aside from this, there is no safe way to update the records "automagically" after the update without reading "dirt" records and keeping an open connection to the database.

It's easy to update trough the provided example, with 2 or 3 short lines of code, so this will not be a big issue.

I suggest you to create a method that updates you data and refreshes the JSON object. This way you will have less duplicated code.

Best.

from aspjson.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.