You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Following the Server-only via WebSocketServer() and Node.js docs, I am loading in an arrow file on the node server using host.host_table("table_one", table);. I want to be able to overwrite this data table and replace it with a new one. What's the best way to do that?
I don't see any docs for the WebSocketServer api but looking at the source code, I see it has an eject_table method which I can use like this:
This seems to work and ejecting a table that does not exist doesn't throw an error. Is this the best pattern?
Note: The only issue I'm running into this is on the client where if the schema of my first file contains a subset of fields on the file that replaces it, the perspective viewer will not display those additional columns. I think I can play around with the perspective viewer, though, and have it reset its filters... This seems to have worked to reset the state on the client:
I'm not sure if I have this right. The docs have a few references to clearing and deleting but I'm not able to glean what all of the proper reciprocal methods are. Here's what I have so far:
On the server
const{ WebSocketServer, table }=require("@finos/perspective");consthost=newWebSocketServer({assets: [__dirname],port: 8080});consttable_id='foo';// Clean up any existing table with this idhost.eject_table(table_id);// Read in the arrow fileconstfile=readFileSync('data.arrow');// Create the tableawaittable(file);// Host the tablehost.host_table(viewId,t)
On the client
// Do I need a clear here at the beginning that mirrors host.eject_table?constserver_table=awaitwebsocket.open_table(table_id);elem.load(server_table);// Reset the config with these two lines. Not sure why both seem necessaryelem.restore({})elem.reset();
This seems to give me the right behavior but throws an error if any columns are dropped between calls to this lifecycle. Here's an example:
I tried putting the calls to .restore and .reset in a try...catch but I still get the error.
My two main questions are:
Do I need to clear the client before calling elem.load again?
Is there a better way of clearing the config to the default?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Following the Server-only via WebSocketServer() and Node.js docs, I am loading in an arrow file on the node server using
host.host_table("table_one", table);
. I want to be able to overwrite this data table and replace it with a new one. What's the best way to do that?I don't see any docs for the
WebSocketServer
api but looking at the source code, I see it has aneject_table
method which I can use like this:This seems to work and ejecting a table that does not exist doesn't throw an error. Is this the best pattern?
Note:
The only issue I'm running into this is on the client where if the schema of my first file contains a subset of fields on the file that replaces it, the perspective viewer will not display those additional columns. I think I can play around with the perspective viewer, though, and have it reset its filters...This seems to have worked to reset the state on the client:Beta Was this translation helpful? Give feedback.
All reactions