What are the basic important things that will be needed to develop an application with ionic2 including Mongodb? - mongodb

I have been previously learning, how to make applications with ionic2, Angular2 --> For Frontend.
And backend--> Firebase.
Now I have to change my backend to MongoDB.So, What all important things I should learn in order to use MongoDB?Please suggest.
Thank you.
Note: Please let me know if any more inputs are needed relating to this.

You can learn following to accomplish a decent backend with mongodb :
Learn mongodb with some latest aggregation features to make sure the your queries are optimized. mongodb has great documentation which can help you. Install mongo shell and play around to get hands on it.
Make sure your have good cluster-replica management to make sure your data is backed up properly.
Extremely important, make sure you add indexes on the fields which you find are reference points for majority of your queries. Trust me, adding a simple index to a commonly referenced field makes a huge difference. Also, just as an addon, check what type of index you would need based on your requirement. There are various available in mongodb documentation.
Make sure you structure your collections in such a way that there are not many $looups(inner joins) however still making sure how you can keep it scalable. It totally depends on your application schema though.
Try hands on Mongodb Map-Reduce as its very handy.
Install RoboMongo, a GUI client for mongodb if you are used to stuff like phpmyadmin.
Node js(optional if required) :
1. Learn express which is really easy. It will help you to get started with basic routing, cors handling , middlewares and such http-web related stuff.
2. Mongoose, which is a mongodb package for node. There are many others, however if you are familiar with ORM then mongoose is really handy to get you going with simple steps.
3. Authentication for RESTful APIs : There are many options available to be honest. However, based on my experience, you can use passport-jwt, which is really simple and effective.

Related

Options for fastapi with graphql and mongo

I would like to start a new project making use of fastapi. i would prefer mongodb as the storage backend and I would also like to have the whole thing 'speak' graphql.
In early 2022; what are the options? I see there's graphene-mongo... but I can't seem to find anything else.
I am trying to develop something with this tech stack but without success so far.
I am a front-end developer and am diving into the full stack universe. After trying many languages, frameworks and databases, this technology stack I found the most interesting for what I intend to do because of its flexibility.
But for now, I could not advance much and also found the same difficulty as you, very few examples available on the web.
My small example application uses FastAPI, is already connected to the MongoDB Atlas database and I tried using the Graphene library to expose a graphql endpoint of the database query result, but so far I haven't achieved any meaningful result.
I have also tried using the Strawberry library, which is suggested by the FastAPI documentation, but haven't achieved much yet either.
I will keep pushing to make this tech stack work and if I succeed, I can share my experience with you if you are still interested.

Angular 4 and Node.js combination

So as the title implies, I have a little problem. I'm developing app with Angular 4 and I would like to us it in combination with Node (mainly for API). So I tried to start both servers, and use it that way, but as i'm currently developing at local machine, so maybe there is better alternatives? Something like MEAN (MongoDb Express Angular Node) combination, but all of those are quite hard to use, there is lack of documentation, and those uses angular 2 instead of 4. I prefer MEAN stack, but I can't find one that are maintained and up to date.
Thank you for your help.
EDIT:
As some answers implied I will properly describe what I did to achieve what I need.
Here is what I have tried:
Having two tools (Node and Angular) to communicate to each other via http protocol (actually this kind'a worked, but node wasn't stable, it broke with connection error to db and Angular would not get response from it until it crashes)
Tried to use Angular proxy settings to enable link rerouting to have wildcard for all links that starts with /api/
Installed few MEAN stacks, tried to test it's potential and decided that it's way to over the limit to achieve what I want.
Tried to combine two tools into one by starting both at same port (as you might imagine, this broke both of them).
You can use MongoDB in your API whithout problems, and also it's not that hard to use it, its really more simple thant DataBases that have relational objects, like SQL, PostGRES and so on. I would recommend Hapi instead Express, but Express have a lot of information on the web, so if you are not confortable with re-search in documentation, Express would be you better option.
When i started developing in node.js it take me time to figure out that tutorials and videos only give me headache, old videos that doesent use the same Frameworks as i do, or not in the same version. So i started to take deep into the documentation, i used to pass more time reading than writing code, and it help me a lot.
The most common/simple is MEAN API, find something you like and stick with it ^-^

Using PostgreSQL or PostgreSQL + MongoDB?

I'm currently planning a social-media application - especially the backend.
Basically I have all the social aspects for which I want to use SQL (PostgreSQL I guess) but I also have geolocations organized in lists (so many-to-one) which will propably make out the biggest ammount of data. I know that PostgreSQL has modules for GIS capabilities and my initial thought was to just use PostgreSQL for everything, just for the sake of simplicity and because performance of Geolocation searches should be around the same for both systems, if not even in favor of PostgreSQL. I can also use JSON Type in PostgreSQL so it basically has the most obvious advantages of MongoDB covered.
On the other hand I'm affraid of scalability as the geolocations are going to be the biggest chunk of data and the tables are propably going have heaps of rows.
So my thought now is to implement geolocations in MongoDB with its easy scalability, easy to use geolocation search and embedd e.g Comments/Likes for a geolocation directly into the document, which would make the geolocation reads/searches way easier but then again I had to combine this data with social data from SQL, e.g fetch all users that commented a geolocation and get their profile info from PostgreSQL and 'manually' combine it. Even though parts of this could be done on frontend saving me a lot of resources.
I'm not sure how good this idea performs and if I'm really doing myself a favor there.
tldr: Use PostgreSQL.
Long answer:
You are trying to pre-optimize for a problem you don't even know if you will have. You don't know how many geolocations you will have, what the usage behaviors will be of your users and you probably don't even have any users yet.
I've used MongoDB before and migrated to PostgreSQL. There are many, many features and benefits to using a 'real' database for storing highly structured data. I suggest googling around for 'PostgreSQL vs X' articles, but the overall consensus that I've found is that PGSQL is extremely mature, reliable, performant and supported.
From my personal experience using Mongo then switching to PGSQL, I will never use Mongo again unless PGSQL (or another full-fledged SQL database) is completely falling over and I've spent months fixing it. Even then I'd take a hard look at other NoSQL databases too. PGSQL has so many amazing features and powerful tools that make it a joy to use.
For the seemingly few things you think you need Mongo for, PGSQL can do, and do just as well or better. It has native JSON types with indexes, geo support, full text indexing, etc. PGSQL has been around longer and has more support (useful for debugging, performance tuning, etc).
Regardless of which technologies you are thinking of using, you can't make any sort of informed decision if you don't:
Test with large data sets
and
Know your usage patterns and data volumes
So at this point I'd pick the more matured and powerful tool and setup monitoring for it. Watch the usage and performance of PGSQL, see how it holds up. Research best practices for PGSQL. Get to know it, learn it, dive in deep. When it comes to scaling individual services, each one is somewhat unique and will not fit a simple "Should I use X or Y?" question.
Good luck!

mongodb and sql for document versioning system

I'm a computer engineer student and i've got a basically simple assignment but i'd like to make it a little more interesting :). Basically I have to create a simple multiuser, online document versioning system using Java or .NET. Because I'm more a .NET guy I'm gonna use ASP.NET or Silverlight (it's not yet decided).
Anyway the intersting part: I want to use MongoDB to store the documents (they can be virtually anything, video, audio, simple MSOffice files, plain text), each version of them and the related metadata (which library, folder they're in etc). I'd like to put anything else, like users, permissions etc.(the specs are not yet completed) in to an ordinary relational database. The question is what do you think about this? Do you think this makes any sense or I'm just trying to over complicate the whole thing? Would it be simpler to use only mongodb for everything or leave the nosql thingy entirely out of it? Is there any conventions for this kind of stuff? :)
BTW. under any other circumstences I'd use some free, battle tested solution for doc versioning, but I have to design and implement this myself, and I'm trying to do it at least a little unconventionally :).
Thanks for every comment:), any help appreciated:)
Greets
If you were using something like Mongoid on Rails, this would be trivial. http://mongoid.org/docs/extras.html Look for Versioning. The ODM has it built in for you. I've yet to use Mongo in the .NET world, it's always been something like Raven, so I'm not sure if the libraries for it easily work like Mongoid does.
Mongo handles relational data as well. Things you want normalized (e.q. user records) can have references to other documents in the DB. And of course what ever magic document you want to store works as well.
Doing things unconventionnaly is usually a good way to discover new ways (better ways ?) so it's a good idea.
Using mongodb is a good idea too because of the schemaless property.
USing a relationa database for storing extra information is quite weird and will add more complexity without any advantage (IMO)

are adhoc queries/updates starting to kill your productivity with MongoDB?

i've been developing a asp mvc website for almost a year now exclusively on mongodb. i've loved it for the most part. development productivity has been great using a C# mongodb driver and tools like mongovue.
however, i've started to reach a point where there are things i really wish i had a SQL server database for. simple tasks like updating a record in the DB and only mildly complex queries to generate some type of report are becoming a pain.
i read an article somewhere that in order for NOSSQL to succeed there needs to be a standard query language for it, and tools developed around it. i'm guessing this is far far away, so right now i'm stuck trying to deal with these things.
i think eventually i will have to have a dual solution with monogDB and sql server. i don't think i will ever get to the point where i am as productive updating and writing queries for mongoDB as i was with sql server.
how are you guys dealing with this when using NOSQL like mongodb? are you facing the same issues as me?
One solution you may consider is LINQPad. You can set up a template with a reference to 10Gen's drivers and write ad-hoc, C# MongoDB queries like you would in your code. My team and I use this method to address the very problem you mention.
Try it out (it's free) and see if it can help with the simple, day-to-day queries you come up with.
Edit I also support Chris's suggestion of familiarizing yourself with the native JSON query language. Nothing beats a quick console window for speed, if you know the syntax.
The official C# driver will probably get a LINQ provider some time in the future, so that'd give .NET devs a familiar syntax for querying and maybe help with initial productivity. There're also some nice docs that help relate MongoDB queries back to SQL:
SQL to Mongo Mapping Chart
SQL to MongoDB (PDF)
These are great for learning, but to get the most out of Mongo it's well worth investing time getting used to the native JSON query syntax and Mongo-specific concepts like map-reduce.
Since your questions asks,
how are you guys dealing with this when using NOSQL like mongodb?
I thought I'd chime in. I felt your pain when working with another NOSQL database, RavenDB.
I wrote a Linqpad driver specifically for ad hoc interactions with RavenDB.
https://github.com/ronnieoverby/RavenDB-Linqpad-Driver