It is possible to fetch data from the repository using typeorm for mongodb - mongodb

I'm making an api in which I separate my requests by responsibilities, services, repository and routes, I'm using typeorm to connect to the database, and I'm trying to implement unit tests to test my application so I have to unclip my code from the typeorm of so that my tests are not depending on it. However, at the time of decoupling, the typeorm is no longer able to connect with the bank, which is mongodb, returns the following error: ConnectionNotFoundError: Connection "mongo" was not found.
I've been reading about it and from what I understood the typeorm wouldn't give full support to the mongo, that's why it failed. I would like to confirm with you if that would be the case and what would be the best alternative to solve this.

MongoDB is supported by TypeORM (although I have not used it personally myself).
You can follow a short tutorial here.
What is not supported for Mongo is the typeorm "Migration" feature. For example see typeorm issue 6695. Migration is an advanced topic and you probably do not need it. But if you do, a workaround is on stackoverflow answer here.
But this Migration issue has nothing to do with your error. Almost certainly, your getConnection() call or ormconfig.json are incorrect. Start a with simple project based on the TypeORM Mongo tutorial, nothing else, verify you can connect to MongoDB, and work up from there.

Related

You must first connect to a database to use Browser Sync in neo4j

i deployed the neo4j in kubernetes, so when i tried to acess http://:7474/ it show me this error( ServiceUnavailable: WebSocket connection failure. Due to security constraints in your web browser, the reason for the failure is not available to this Neo4j Driver.), hoe can i solve it?
You need to uncomment a single line inside $NEO4J_HOME/conf/neo4j.conf:
dbms.connector.bolt.address=0.0.0.0:7687
The issue is well described here
If you're using Neo4j Helm instead of neo4j.conf you will have values.yaml. also it is well described here.

Prisma 2 with different databases

I'm new at prisma 2 but have got a database working. I have used prisma 'init' and 'migrate dev' to create database tables for my model and can interact with the database using the Prisma client - prisma 2.22.1
Usually for a project, I'd have dev, test and prod environments and use env-cmd to set the relevant differences, e.g. connection details for getting to the database.
With prisma 2 however, it seems like there's a single .env file that is used for the database connection details, so I cannot see how to proceed for the different environments.
Note that I'm not meaning different types of database - in this example all are postgresql.
I can see possibilities for getting past this hurdle, for example for the script to write a suitable .env file according to the required environment as part of running the app, but 'not ideal' really doesn't give this idea the review that it deserves. Or getting more computers.
Any suggestions please for using different databases from the same project? Am I missing something basic or is it deliberately blocked?

Use AWS Amplify and App Sync with existing Node Server using Mongodb

Currently, I'm developing a native application using React-Native. I've decided to go with AWS Amplify because of it's real time updates as well as its authentication.
I also have a Web Application that runs on a Node.js with Epxress server. This web application connects to a Mongo database.
My big problem is that I would like to have all of my aws amplify queries run to my existing MongoDb instead of a new dynamoDb database which is provided with AWS AppSync, but unfortunately I dont know where to start. This is especially helpful in adding authentication easily in my existing web application as well.
My first idea was to just create all my API endpoints in a new node js server and have app sync call to these API end points, but I'm not sure how to implement calling end points on an existing server (and this seems kind of counter intuitive to the 'serverless' idea)
My other idea came from this: Can AWS App-Sync be used without dynamoDB
This states to use AWS Lambda to 'pipeline' my data to the existing mongodb, but I'm not really sure what that entails.
TL;DR - I would like to be able to query an existing Mongodb instead of using DynamoDb when using AWS Amplify with AppSync.
I hope this is clear enough and doesn't sound like I'm rambling. Thanks in advance!
I would suggest using either an HTTP datasource to connect to your MongoDB backend or a Lambda function. Here are a couple getting started tutorials for both:
https://docs.aws.amazon.com/appsync/latest/devguide/tutorial-http-resolvers.html
https://docs.aws.amazon.com/appsync/latest/devguide/tutorial-lambda-resolvers.html
If you go the Lambda route, then you can leverage the new #function feature of the GraphQL Transformer in the Amplify CLI: https://aws-amplify.github.io/docs/cli/graphql#function

Spring REST MongoDB Starter Application queries

So I used the Spring MongoDB application starter kit from Github. I tried running the application and it ran great. All the functionality work great. I am confused how the connection for this is being established. Where does one specify the db userid, password and the db name? Coming from a MySQL background, though MongoDB isnt a mountain there are some differences that dont set clearly in the mind of newbies.
I followed the official documentation from here : https://spring.io/guides/gs/accessing-mongodb-data-rest/. Maybe can the above info be added to the docs?
You should read some docs on Springboot. Springboot is opinionated. That means it assumes lot of stuff and sets-up lot of things for you. For example, in your case, As soon as it sees mongo dependency in your pom. It will create a connection to mongodb with default values which are as follows
host: localhost
port: 27017
username:
password:
database: test
That is how it is working. But if you want it to be customized, even that is made easy by specifying in configuration files (application.properties or yaml). See the list of configuration properties that you can set
https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html

WARN org.springframework.web.servlet.PageNotFound - Request method 'POST' not supported

Os is Mac Os Maverick.
In a jhipster context (last version, 1.2.2), I get an error when I request the default application on an entity I have just generate using yo jhipster:entity generator.
I run a yo jhipster to create a vanilla application with mongodb as database, java 7 and nothing special.
Then I run grunt build and grunt server for hot reload on the client part and mvn spring-boot:run for the server side app.
When I go to the http://localhost:8080/ url, I get the normal page. I can sign in with either the user or admin login.
I run the yo jhipster:entity foo to get an exemple of rest service in the back end.
When I request for the foo resource with the URL http://localhost:8080/#/foo, I get the page to CRUD the resource as it is said on the jhipster website.
But when I try to create a foo item with the modal form, I get an error on the back end server log ([WARN] org.springframework.web.servlet.PageNotFound - Request method 'POST' not supported).
I can't figure out how to solve this.
Do I miss something in the documentation ?
Do you have any idea, hint ?
I have the same issue using H2 as development database instead of mongodb.
Thanks.
Hervé
This might be due to MongoDB, if you have a date field.
We will release very soon a new and improved Entity sub-generator, which should work better for you. While testing it, I had a serialization issue with MongoDB and a date field, and I corrected it in this new version. This is due to Jackson which can't serialize Joda Time dates (the correct annotations were only generated for SQL databases, not NoSQL databases)