Giter VIP home page Giter VIP logo

Comments (4)

MichaelSolati avatar MichaelSolati commented on May 30, 2024 1

The set function requires a full document, so the original with modifications, not just the modifications (as it looks for coordinates). So you'll want something like this:

const restaurantsGeostoreRef = db.collection('exploreMap');
const restaurantsRef = new GeoFirestore(restaurantsGeostoreRef);

export const addNewRestaurant = (data) => {
    const doc = {
        ...data,
        coordinates: new firebase.firestore.GeoPoint(data.coordinates[1], data.coordinates[0]),
    };

    restaurantsRef.add(doc)
        .then(docRef => restaurantsRef.set(docRef.id, { id: docRef.id, ...doc })
            .then(() => 'Successfully added.')
            .catch(error => error)
        ).catch(error => error);
}

from geofirestore-js.

MichaelSolati avatar MichaelSolati commented on May 30, 2024 1

@AndrewAi I would advise you to use the libraries set method, as it has to parse your document for changes/adjustments. However for remove it wont matter.

from geofirestore-js.

24dev avatar 24dev commented on May 30, 2024

Works, appreciate it!

from geofirestore-js.

AndrewAi avatar AndrewAi commented on May 30, 2024

Can I still use firestore's set method, or would it be better to using geofirestores implementation of the set method? similarly with the remove method, if I just remove the document, it will just be deleted but all the other won't be affected.
Thank you for the library, its brilliant so far!

from geofirestore-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.