Reputation: 7107
The Azure Storage library for NodeJS shows creating a Task as follows:
var azure = require('azure-storage');
var entGen = azure.TableUtilities.entityGenerator;
var task = {
PartitionKey: entGen.String('hometasks'),
RowKey: entGen.String('1'),
description: entGen.String('take out the trash'),
dueDate: entGen.DateTime(new Date(Date.UTC(2015, 6, 20))),
};
But is it possible to store an object (e.g. Like Stuff):
var azure = require('azure-storage');
var entGen = azure.TableUtilities.entityGenerator;
var task = {
PartitionKey: entGen.String('hometasks'),
RowKey: entGen.String('1'),
description: entGen.String('take out the trash'),
dueDate: entGen.DateTime(new Date(Date.UTC(2015, 6, 20))),
stuff : { "abc" : "def", "ghi" : "jkl", "mno" : { "pqr" : "stf" }}
};
Or do I need to JSON.stringify it and store it as a string?
Upvotes: 0
Views: 448
Reputation: 71120
In your case, stuff
is JSON. Table Storage entities don't have a JSON
type. You'd need to stringify, resulting in a String
type.
You could also choose to use separate properties for each element in your JSON doc (and every entity could contain different properties - no schema is enforced; you'd just need to give yourself a hint on stored object type, so that you could retrieve the properties as needed). And yes, that gets trickier as you continue to nest JSON objects, as your example does.
FYI all supported Table entity types are listed here.
Upvotes: 1