Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/457.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用firebase从我的Api发布地质点_Javascript_Node.js_Firebase_Express_Google Cloud Firestore - Fatal编程技术网

Javascript 如何使用firebase从我的Api发布地质点

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 {

我是一名编码新手,我正在制作我的第一个Api

我的问题是,我试图在firestore数据库中发布一些地质点,但看起来不可能。下面是我的代码:

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)),