Reputation: 461
I'm working on azure mobile services scripts. While being in insert script code of one table I want to insert a record in another table. I know it is possible using table.insert() function, but I'm not finding out a way to initialize a table object inside the script. The script doesn't recognize the Table name as a type that could be initialized. May be I'm missing some basic point. Following code might help you understand:
function insert(item, user, request) {
Misc misc = new Misc(); // 'Misc' is the table name and it is not recognized as a type.
misc.name = "John";
var tblMisc = tables.getTable('Misc');
tblMisc.insert(misc);
...}
Upvotes: 1
Views: 117
Reputation: 2620
Azure Mobile Services scripting language is Node.js which is dynamically typed, so Misc misc = new Misc();
won't work.
You could change your first line to:
var misc = {};
Or just replace everything with:
tables.getTable('Misc').insert({ name: "John" });
Upvotes: 3