Is my understanding that these objects are just floating around unassigned until I send a createCommit mutation to assign it? I was reading this topic Updating Speckle Streams from JS to figure out how the objectCreate and createCommit work…
Yes, All objects exist forever in an ever-expanding list.
Commits are the principle mechanism to determine a specific project version at a point in time.
Commits could be engineered to make completely hybrid collections of objects also. The creation timestamp of an object is a datapoint on each object, independent of the commit.
Draw down a commit object with GraphQL. All the constituent objects are listed as referenceObjects because serialization happens before the commit object is created.
So theoretically you could create a commit that grabs all of a specific object (if you have the reference ids), to create a timeline of some data point? That’s neat.
@jonathon I have the objectCreate and createCommit working, but I don’t have access to crypto-random-string; do ids need to be hashed from the contents of the object or can I just use uuids? Is there some way to create ids manually?
PPS
If you are, instead, running your code not on a nodejs server nor wrapping it up with webpack the equivalent library is [crypto-js](https://github.com/brix/crypto-js)
Hashing helps us to do checksum between objects. If you hash same object twice, you will get the same id. By this way we can check objects are exist before or not in any scope (server, host program…). So ideally hashing should be the way to go.
That’s correct unless you do care the “unassigned” object state in host program. If do so, you need to hold state of the object and it’s id to follow lifecycle of the objects. That was the main reason as @jonathon said, I refactored this serialization process to Ruby for SketchUp connector.
For context I’m using retool.com to build a CRUD dashboard. It’s limited what javascript libraries I can use with it, but I think crypto-js is working, although I couldn’t call the createHash function (can only use the functions directly inside of crypto-js), instead I’m passing the object into cyrpto.MD5(obj).toString() to generate an id where obj is my object to be committed - it seems to be working? Let me know if this isn’t a valid way of generating ids…
I haven’t got nested objects at the moment but if you can point me to an example somewhere that would be helpful (the batchObject function from the serialization.js example @jonathon?)
It’s only more complicated in that you start to get into potentially needing to detach (only if you want to), which would mean incrementally traversing the objects as you serialize.
You can hash the objects any way you wish if you are always in control. If it consistently produces a unique hash, then you’re relatively fine.