How do I get the latest values from a select

I have modified the CityContent name multiple times. How do I get the latest value. This select gives me all modified values for ‘name’.“v:Ccid”, “v:City Content Id”, “v:City Id”, “v:City Name”).and(
WOQL.triple(“v:CityContent”, “type”, “scm:CityContent”),
WOQL.triple(“v:CityContent”, “cityContent_id”, “v:City Content Id”),
WOQL.triple(“v:CityContent”, “ccid”, “v:Ccid”),
WOQL.triple(“v:CityContent”, “ccity_id”, “v:City Id”),
WOQL.triple(“v:CityContent”, “name”, “v:City Name”)

Hi orioncri,

According to the query posted, you want to view Ccid, City Content Id, City Id and City Name of type scm:CityContent. So you should get just these property values for each CityContent you have in your database. Regarding you modifying values for CityContent name multiple times => what ever your latest value is, will be appearing as the recent v:City Name.

You should see this value, maybe eyeball your commit history to see if inserting your latest value succeeded or not?

The query I sent you gives me all versions of the class row. I need ONLY the latest modified row. Currently I am getting ALL rows. Remember I had to use the delete_triple and add_triple to modify a property. The update_triple did not work for me.

This is slightly involved.

If you have a triple (“v:A”, “v:B”, “v:C”) and I want to found out when it was last updated, you can query the commit graphs for the time. Given a COMMIT_ID, the following query will tell you whether the triple was updated in that specific transaction:

let v = "f92h1w1ewizmsm6v6gdhaguu9le5uap"

	using("admin/knowledgex/local/commit/" + v).added_triple("v:A", "v:B", "v:C"),
        using("_commits").triple("v:Commit IRI", "ref:commit_id", v).triple("v:Commit IRI", "ref:commit_timestamp", "v:Timestamp") 

If this returns any results, the triple was updated in this commit and the variable v:Timestamp will contain the timestamp

What makes it slightly intricate is that you have to assemble the query from another query which gives you all the relevant commit ids to check.

There are a bunch of library queries which return lists of commits depending on your exact situation:
WOQL.lib().active_commit_id(branch, timestamp) will give you the commit id that was active at any particular / branch / time combination, they you can use:
WOQL.lib().previous_commits(commit_id, count) and WOQL.lib().next_commits(commit_id, branch, count) to navigate the commit graph. You can combine these queries as so:

    WOQL.lib().previous_commits("v:Commit ID", 100) 
1 Like

TerminusDB needs to create a WOQL.bundle(Branch) function that creates a GIT like Bundle that can be imported or Merged into the Main or sister Branch at a different network location. Sounds like you have capability with your previous comment.

1 Like

Yeah, that’s very close to what I wrote above. I’ll do them both at the same time (the Javascript client and CLI).