modify google maps engine tables from node
Wrapper for doing crud operations on Google Maps Engine tables.
No affiliations with Google blah blah etc.
All methods return promises.
var GME = require'gme';GMEcreateTablekey email requestObj;var table = key email tableID primaryKey;table.info; //-> info about the tabletablefeatures; //-> all the featurestablereadStream; // -> same but read streamtablefeaturesquery; //-> filtered listtablereadStreamquery; // -> again same but with a read streamtablefeatureid; //-> one featuretablecreatearray; //-> success/failuretableupdatearray; //-> success/failuretableremovearray; //-> success/failure// Using bulk operationsvar bulk = tablebulk;bulkcreate|update|remove; //-> ready for more/failurebulkflush; //-> success/failure// Using streams to write multiple rowsvar stream = tablewriteStream;streamwritetype: 'create'value:;streamwritetype: 'update'value:;streamwritetype: 'remove'key: 'string';
key and the
Once you obtain the private key, you must convert it to a pem file, with something like
openssl pkcs12 -in key.p12 -out key.pem -nodes, where
key.p12 is the downloaded file from the Service Account and
key.pem is the file you pass as the
key argument. The key parameter may either be the buffer contents of the key file or the string path to the keyfile.
tableID arguments must be strings,
primaryKey is optional and defaults to
For remove an array of ids to delete is required.
bulk doesn't return a promise, but instead it returns a bulk object, which has the same create update and remove methods that work the same way, the only difference is that they wait util they have the maximum number of features or verticies and then does the upload in a batch.
bulk.create(feature); the first 49 times will return a promise that resolves to
true but the 50th time it is a promise for the bulk upload of all 50 features.
bulk.flush forces an upload of all items in the current queue and cleans them out, flush doesn't close the object or anything so you can continue to use it.
writeStream method returns a writable stream, write objects with a
type property with 'create', 'update', or 'remove' value and then a 'data' property with the object or string to put to the method (this can also be named 'key' if you want).
Similar to the table constructor but instead of a table ID takes a table creation object.
Either returns all the rows or a filtered set based on a query, the only difference is that features returns a promise while readStream returns a stream., see this page for query options. Note that table.features does the pagination for you, you don't need to worry about it.