我将以这种方式向您描述...
这是我的功能:
fn: async function({address, country, zipCode}){
const response = await geocoder.geocode({
address: address,
country: country,
zipcode: zipCode,
minConfidence: 0.5,
limit: 1
})
return response
}
我以这种方式运行此功能:
fn: async function(inputs, exits){
//HERE
const location = await sails.helpers.party.geocoder(inputs.address, inputs.country, inputs.zipCode)
console.log(location)
}
她向我返回了此类数据:
[ { latitude: 52.6997543,
longitude: 15.2602551,
country: 'Poland',
city: 'Gorzów Wielkopolski',
state: 'Lubusz Voivodeship',
zipcode: '66-446',
streetName: 'Zieleniecka',
streetNumber: '4',
countryCode: 'pl',
county: 'Gorzów Wielkopolski',
extra: { confidence: 10, confidenceKM: 0.25 },
provider: 'opencage' } ]
下面是我的数据库模型:
module.exports = {
attributes:{
latitude:{type:'number'},
lonitude:{type:'number'},
country:{type:'string'},
city:{type:'string'},
state:{type:'string'},
zipcode:{type:'string'},
streetName:{type:'string'},
streetNumber:{type:'string'},
countryCode:{type:'string'},
county:{type:'string'},
provider:{type:'string'},
}
}
我的问题是:如何将函数返回的数据映射到我的模型?
我真的需要帮助,有人可以帮助我吗?