Javascript 如何使用firebase从我的Api发布地质点
我是一名编码新手,我正在制作我的第一个Api 我的问题是,我试图在firestore数据库中发布一些地质点,但看起来不可能。下面是我的代码:Javascript 如何使用firebase从我的Api发布地质点,javascript,node.js,firebase,express,google-cloud-firestore,Javascript,Node.js,Firebase,Express,Google Cloud Firestore,我是一名编码新手,我正在制作我的第一个Api 我的问题是,我试图在firestore数据库中发布一些地质点,但看起来不可能。下面是我的代码: const db = admin.firestore(); const pointGps = new admin.firestore.GeoPoint(Number, Number); app.post('/api/createrdv', (req, res) => { (async () => { try {
const db = admin.firestore();
const pointGps = new admin.firestore.GeoPoint(Number, Number);
app.post('/api/createrdv', (req, res) => {
(async () => {
try {
await db.collection('rvlist').doc() // CREATION AUTO DE L'ID // POUR CREER AVEC ID PERSO ('/' + req.body.id + '/')
.create({
//id: req.body.id,
latlong: pointGps({lat: req.body.lat, lng: req.body.lng}),
name: req.body.name,
phone: req.body.phone,
psnumber: req.body.psnumber,
rvtime: req.body.rvtime,
vu: req.body.vu
});
return res.status(200).send();
} catch (error) {
console.log(error);
return res.status(500).send(error);
}
})();
});
错误:参数“纬度”的值不是有效数字
同样的问题,我不能将数据库用于任何时间戳
有没有关于如何做到这一点的想法,或者至少firestore可以做到这一点?两天后我就被卡住了试试这个:
const db = admin.firestore();
app.post('/api/createrdv', (req, res) => {
(async () => {
try {
await db.collection('rvlist').doc() // CREATION AUTO DE L'ID // POUR CREER AVEC ID PERSO ('/' + req.body.id + '/')
.create({
//id: req.body.id,
latlong: new GeoPoint(Number(req.body.lat),
Number(req.body.lng)),
name: req.body.name,
phone: req.body.phone,
psnumber: req.body.psnumber,
rvtime: req.body.rvtime,
vu: req.body.vu
});
return res.status(200).send();
} catch (error) {
console.log(error);
return res.status(500).send(error);
}
})();
});
如果你需要答案,多亏了tobzilla
app.post('/api/create', (req, res) => {
(async () => {
try {
await db.collection('psdata').doc() // CREATION DE L'ID AUTOMATIQUE // POUR CREER AVEC ID PERSO ('/' + req.body.id + '/') //
.create({
//id: req.body.id,
latlong: new admin.firestore.GeoPoint(Number(req.body.lat),
Number(req.body.lng)),
city: req.body.city,
name: req.body.name,
phone: req.body.phone,
psnumber: req.body.psnumber,
speciality: req.body.speciality,
streetadress: req.body.streetadress,
zipcode: req.body.zipcode,
});
return res.status(200).send();
+1 GG!我的英雄哈哈,所以我使用你的想法,使用这行代码,它工作得非常完美,我可以直接在firestore数据库latlong中发布coordonate:new admin.firestore.GeoPoint(Number(req.body.lat),Number(req.body.lng)),