Is there anyway of setting datastore to use firebase firestore emulator? i.e Datastore in native mode

42 Views Asked by At

I am using datastore from google-cloud-cpp. I have a Firestore emulator running on the same project as my data store. My datastore API is datastore in native mode, which is Firestore.

// namespace FIRESTORE = google::cloud::FIRESTORE;
template <typename ModelType>
class Firestore
{
public:
    // Constructor
    Firestore()
    {
        auto &app = drogon::app();
        auto customConfig = app.getCustomConfig();

        project_id = customConfig.get("gcloud_project_id", "default-project").asString();

        // Initialize the Firestore client with the necessary connection
        google::cloud::Options options;
        // Specify the emulator endpoint. This URL is just an example; adjust the port as needed.
        //std::string emulator_endpoint = "http://localhost:9019";

        // Create client options with the emulator endpoint
        //auto options = google::cloud::datastore_v1::ClientOptions::CreateDefaultClientOptions().value();
        //options.set(emulator_endpoint);
        // options.set<google::cloud::ProjectIdOption>(project_id);
        client_ = std::make_unique<google::cloud::datastore_v1::DatastoreClient>(
            google::cloud::datastore_v1::MakeDatastoreConnection());
    };.

I wonder if there is a way to set this up to use a local emulator, and if so, can it be connected to the Firebase Firestore emulator?

0

There are 0 best solutions below