<div dir="ltr"><div><div>Hello,<br><br> </div>I'm landing bits of the datastore API, a couple of patches still outstanding.<br><br></div>You create an object like this.<br><div><br>function onStream(outputStream) {<br>
outputStream.write(arrayBuffer);<br> outputStream.close();<br>}<br></div><div><br>datastore.create(metadata, onStream, onCreated);<br><br></div><div>Then you can load the data for an object with something like<br><br>
function onRead(arrayBuffer) {<br>}<br><br>function onStream(inputStream) {<br> inputStream.read(8192, onRead);<br> inputStream.close();<br>}<br><br>datastore.loadData(objectId, onStream);<br><br></div><div>Finally you can get the metadata for an object with<br>
<br>function onGotMetadata(metadata) {<br>}<br><br>datastore.getMetadata(objectId, onGotMetadata);<br><br>I consider this a low level layer, exposing the basic datastore
operations. We will have to build a friendlier
API on top. There are a couple of things that should be easier:<br><br></div><div>* Use in memory structures like text and blob rather then streams to load/save the data.<br></div><div>* Use the default actiivity object rather than always specifying an objectId.<br>
<br></div><div>I'm thinking of something like this.<br><br></div><div>Save an object<br></div><div><br>textObject = datastore.TextObject();<br>textObject.setText("Hello");<br>textObject.setMetadata({"title": "hello"});<br>
textObject.save(onWrote);<br><br></div><div>Load an object<br><br>textObject = datastore.TextObject();<br>textObject.load(onGotText);<br>textObject.getMetadata(onGotMetadata);<br><br>The TextObject constructor would take an optional objectId. If not specified it is the default activity object. Other type of objects could be made available, datastore.BlobObject for example, with similar API.<br clear="all">
</div><div><div><div><br></div><div>Thoughts?<br></div><div><br>-- <br>Daniel Narvaez<br>
</div></div></div></div>