Storing a Date Property for an Azure Table Storage Entity with Mobile Services and Node.js -


i'm working windows azure mobile services custom apis , windows azure sdk node.js.

i have simple script starts importing azure module.

var azure = require('azure'); var tableservice = azure.createtableservice(); 

in response post custom api, insert entity azure table storage (not azure sql database) handful of properties, 1 of timestamp (an instance of date).

    var entity = {       partitionkey: partitionkey       rowkey: rowkey,       time: new date()     };      tableservice.insertorreplaceentity(tablename, entity, callback); 

the result time property stored entity string instead of date. example, time property stored string mon aug 12 2013 20:32:51 gmt+0000 (coordinated universal time). i've confirmed loading table server explorer in visual studio , examining details of inserted entity.

i know can store dates in azure table storage , i've done c#. however, above not work , cannot think of more canonical example test custom api written in javascript.

see how use table service node.js shows similar example.

so how store date property expected data type using azure node.js sdk?

this example save time property using wcf datetime data type. using code:

var azure = require('azure'); var tableservice = azure.createtableservice(accountname, accountkey, host);  tableservice.createtableifnotexists('testtable', function(error){   if(!error){     var item = {partitionkey: "things"                 , rowkey: "123"                 , name: "thing add"                 , category: "test"                 , time: new date()};     tableservice.insertorreplaceentity('testtable', item, function(error){       if(!error){         console.log('item inserted');         tableservice.queryentity('testtable'           , 'things'           , '123'           , function(error, entity){               if(!error){                   console.log(entity);               }           });       }     });   } }); 

if run code, get:

done item inserted { _:    { 'xml:base': 'https://xxxxxx.table.core.windows.net/',      xmlns: 'http://www.w3.org/2005/atom',      'xmlns:d': 'http://schemas.microsoft.com/ado/2007/08/dataservices',      'xmlns:m': 'http://schemas.microsoft.com/ado/2007/08/dataservices/metadata',      etag: 'w/"datetime\'2013-12-12t16%3a11%3a38.118877z\'"',      contentrootelement: 'm:properties',      id: 'https://xxxxxx.table.core.windows.net/testtable(partitionkey=\'things\',rowkey=\'123\')',      category: { '$': [object] },      link: 'testtable(partitionkey=\'things\',rowkey=\'123\')',      title: '',      updated: '2013-12-12t16:11:38z',      author: { name: '' } },   partitionkey: 'things',   rowkey: '123',   timestamp: thu dec 12 2013 16:11:38 gmt+0000 (gmt standard time),   category: 'test',   name: 'thing add',   time: thu dec 12 2013 16:11:38 gmt+0000 (gmt standard time) } 

this showing datetime value rather string time field. shows datetime field in visual studio table storage viewer/editor.

if query same table using c# code, c# datetime value time field.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -