Does Azure Table Storage only support String as a data type?

I am trying to insert data into an Azure table, but everything is converted to rows.

eg. I insert numbers / booleans

var test={ PartitionKey : '4', RowKey : '2', foo: 4, bar: true }; tableService.insertEntity('mytable', test, ...); 

but

 tableService.queryEntity('mytable', '4', '2', ...); 

returns

 { id: 'http://127.0.0.1:10002/devstoreaccount1/identid(PartitionKey=\'4\',RowKey=\'2\')', link: 'identid(PartitionKey=\'4\',RowKey=\'2\')', updated: '2012-12-12T10:26:44Z', etag: 'W/"datetime\'2012-12-12T10%3A26%3A44.547Z\'"', PartitionKey: '4', RowKey: '2', Timestamp: '2012-12-12T10:20:44.897Z', foo: '4', bar: 'true' } 

How can I specify a data type?


OK, just saw in the SDK that you can specify the data type with

 var test={ PartitionKey : '4', RowKey : '2', foo: { '@': { type: 'Edm.Int32' }, '#': 4 } }; 

however, are there any helper functions for automatically adding a type?

+4
source share
2 answers

Since the SDK does not contain anything useful, I wrote this now:

 function azType(type, v) { return { "@": { type: type }, "#": v }; } function azBool(v) { return azType("Edm.Boolean", v); } function azBinary(v) { return azType("Edm.Binary", v); } function azByte(v) { return azType("Edm.Byte", v); } function azDateTime(v) { return azType("Edm.DateTime", v); } function azDateTimeOffset(v) { return azType("Edm.DateTimeOffset", v); } function azDecimal(v) { return azType("Edm.Decimal", v); } function azDouble(v) { return azType("Edm.Double", v); } function azGuid(v) { return azType("Edm.Guid", v); } function azInt64(v) { return azType("Edm.Int64", v); } function azInt32(v) { return azType("Edm.Int32", v); } function azInt16(v) { return azType("Edm.Int16", v); } function azSByte(v) { return azType("Edm.SByte", v); } function azSingle(v) { return azType("Edm.Single", v); } function azString(v) { return azType("Edm.String", v); } function azTime(v) { return azType("Edm.Time", v); } 

how in

 var test={ PartitionKey : '4', RowKey : '2', foo: azInt32(4) }; 

I do not know why they changed it, but starting with 0.6.10, the azType function should be replaced:

 function azType(type, v) { return { "$": { type: type }, "_": v }; } 
+4
source

Only these 8 types are supported by the tab service data model:

  • Edm.Binary
  • Edm.Boolean
  • Edm.DateTime
  • Edm.Double
  • Edm.guid
  • Edm.int32
  • Edm.int64
  • Edm.string

via http://msdn.microsoft.com/en-us/library/windowsazure/dd179338.aspx

and be careful with the id property in your object:

{ PartitionKey : '4', RowKey : '2', id: azInt32(4) };

if you try to do this, the error message is not so obvious:

Error inserting : { [Error: [object Object]] code: 'PropertiesNeedValue', message:{ _: 'The values are not specified for all properties in the entity...','$': { 'xml:lang': 'en-US' } } }

+1
source

All Articles