Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

Connect to MongoDB in ReactNative (using Expo)

$
0
0

i am trying to build a simple connection to a mongodb.If possilbe i would like to use mongoose for that. I am using React Native and Expo.I have seen that in the documentation of MongoDB it says that i can`t use Realm with Expo. Thats the reason for trying with mongoose. Is this even possible?

import mongoose from "mongoose";const mongoURL = '***';mongoose.connect(mongoURL);const db = mongoose.connection;db.on("error", console.error.bind(console, "MongoDB Connection error"));

This is part of my App.tsx

My tsconfig.json is this

{"extends": "expo/tsconfig.base","esModuleInterop": true,"compilerOptions": {"allowSyntheticDefaultImports": true,"module": "esnext","jsx": "react","strict": true  }}

So far when building the app on my android device i get the error_mongoose.default.connect is not a function

Haven´t been able to resolve this with past questions yet.

I am also open to other cloud-based databases

Is this even the right approach?


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>