what are the nodejs datatype equivalent of the following thrift datatypes -
List
Set
Map
This is my .thrift file.
struct Person{
1: required string name_;
2: required map<i64,string> attribute1_;
3: required map<i64,i64> attribute2_;
4: required map<i64,string> attribute3_;
}
service ProcessPerson {
void DoPerson(
1: required list<Person> person_array
)
}
In the nodejs client, while calling the DoPerson method, what should be the datatype for person_array? Is it an array of objects?
node.js doesn't add any specialized collection datatypes beyond those which are in javascript: Array and Object. If you are looking for similar functionality to List, Set and Map, I would take a look at underscore. It adds convenience methods for iterating, grouping, sorting, filtering, etc.
Yes, the equivalent to your example would be an array of objects:
var person = {
name: "Kevin Bacon",
attribute1: {1:"one"},
attribute2: {1:"two"},
attribute3: {1:"three"}
};
function DoPerson(prs){
var person_array = [person];
}
The List is an array. The Map is an object and the Set can be:
_.uniq(person_array)
Node.js doesn't over anything over native javascript, though there are modules available that implement the data types you are looking for