jhipster - how to load data from a database and show data? - jhipster

I'm learning JHipster and a beginner (web developper).
Can someone show me step by step for loading data in a database (h2 or mysql or oracle) within JHipster application and showing to the home page?
Thanks in advance,

First, you should look at the jhipster documentation to generate an app : see this 12 minute video tutorial
Jhipster actually does a lot for you, it generates the back-end with your classes, logging, database interfacing ... But also creates a nice-looking front-end for you.
Next you should have a database up and running. In the choices you have mentioned, I think Mysql could be the most interesting for a beginner as you would have a good visibility on your database (h2 is mostly in memory, I use it for testing on my app) and the install should be simple enough.
In order to do that, you could use docker or install it manually.
For docker, you just have to type the following command :
docker run -p 3306:3306 --name mysql_instance_01 -e MYSQL_ROOT_PASSWORD=pass -d mysql
And then if you want to stop it :
docker stop mysql_instance_01
See the docker documentation for more information about install and usage : this link
To connect and administrate your database graphically, you can use dbeaver, it is free and easy to use.
Once you have generated the app and the database is running, you have different options : either you add your 'entities' and manually populate your database, or you create an SQL script to do it for you (Which is specific to the database you're using).
JHipster is using liquibase which will automatically translate the entities created in Jhipster into your database.
This is a short introduction, I strongly advise you read the jhipster documentation. For example, this video shows what Jhipster can do and how to use it.
Hope this helps.

You can read this link, a basic jhipster example

Related

problem after moving from sqllite3 to postgresql database in django

enter image description hereI have changed an existing database for a Django project from SQLite3 to PostgreSQL. As presently i am in development environment, and was carrying some dummy data in my SQlite3 so do not need that data.
After changing the database from sqlite3 to PostgreSQL, I run the makemigrations, and migrate commands, and then created a super user.
Now when i try to access the admin panel, by http://127.0.0.1:8000/admin/ django is showing me the following error. I have search a lot for the solution, but failed. I would be grateful, if you could please help me in this.
errorerror2
Looks like your sessions wasn't migrated properly.
Ensure that you have django.contrib.sessions in INSTALLED_APPS and try migrate the sessions again from scratch.
You can do it running:
$ python manage.py migrate --fake sessions zero
$ python manage.py migrate sessions

Creating a Web UI for StrongLoop build & deploy processes?

I want to build web ui for StrongLoop. It would let a user build and deploy process with that UI like StrongLoop Arc.
There are simple node applications(Web Services) without created with StrongLoop tools. Need to deploy these applications via web ui. Solution in my mind is some server-side processes, listed steps below:
Upload zip folder(node application) to server
Extract zip and build to tar.gz by shell command (slc build) through node.js child_process API
Deploy tar.gz file to relevant StrongLoop host by shell command(slc deploy..) through API which is mentioned on previous step.
I wonder is there any alternative way to deploy node application(without created with StrongLoop tools) to StrongLoop host via web ui using some StrongLoop API?
I have looked API could not find specific solution.
What you require is a CDP (Continuous delivery pipeline) setup, there seem to be many ways in which you can achieve this (easiest way is using Codeship or similar platforms), but if you want to know how it works it requires a bit of orchestration tools to help you. To describe the steps I'll be using the following tools:
Docker (what is docker?)
Ansible (Use Cases and How it works?)
Jenkins (What is it and Why to use it?)
"There are many other combination of tools that you can look at, but this should give you an idea"
Now that we have the tools, I'll try to describe the deployment pipeline with a very basic use-case.
Step I "Ideally" - Creating a docker image for your nodejs application.
What generally everyone suggests is that you create a docker image of your application. Then save this image on docker-hub. How this will help you is that, now your nodejs application is contained inside a docker image which makes it independent of the Host and can be deployed anywhere you want.
To create this image all you need to do is create a Dockerfile, which is described in the in the link I've shared.
Step II "Ideally" - Creating an Ansible playbook to mimic the setup steps of your application.
Ansible playbooks are basically used to automate every manual process that you would need to do in order to setup-deploy-run your application. This decreases the need to run even trivial tasks like "slc build".
Step III "Ideally" - This is where we get to the UI stuff
By using Jenkins, you are given a UI which will help you configure tasks that can be combined with Github hooks and trigger the deployment as soon as you make a commit. This is explained in more details in the link shared.
So to summarize, This is what goes on at back to some extent, in order to automate the build and deployment of your application using UI. I hope this serves as a good starting point to achieve your requirements, and also in case you want skip these steps in the start, you could always go with Codeship or similar other tools to help you with the steps that you've mentioned.

docker compose django and node

I am trying to make an application in django via docker and I want separate the backend (django) container from frontend (node, react) container using only one repository.
I want to run node commands from django container (for example: npm init and creating the package.json at main folder).
Is it a good pratice?
If yes, how can I do this?
Thanks in advance.
If you only need Nodejs for building, you should have one docker image just for building (and if you want, deploying) the static files, and then use a whole different docker setup for the actual production environment.
You can look at https://github.com/dkarchmer/django-aws-template (disclaimer, I am the developer) to see an example. Unfortunately, the project is not yet fully tested and documented, but shows how I propose to handle static files outside Django (it does emulate what I do for real in production - just not fully tested).
You will see a top level docker image I use only for building the webpack type project (using gulp), and actually releasing that directly to S3. The top level index.html file gets copied to the django templates directory, to be used as the base template by other django templates (you may not need this if your front-end will be 100% independent of Django). But IMO, I find it useful to mix. For example, I do all the authentication portion using regular django (django-allauth).
Your question is fairly open ended (not exactly a good way to ask in SO), but I hope the link above gives you some ideas on how to implemented what you need.

Is there a way to self-host mongoose databases?

I am getting started with writing an API for a project and the tutorial I am following suggests I sign up for a hosted solution. I think that is ridiculous. My project is simple and I do not feel the need to be locked in to a service. If it helps, I am using Express.
Mongoose is a node.js module (library) which is used to interact with a database, called MongoDB.
There are some websites like mongolab.com which offer plans for development for free, so you would jsut need to sign up and you will get a database without installink anything in your computer/server etc. This is why they say it is easier.
You can install MongoDB in your local computer to test (I think most of us have it) and use just that one for developing and testing.
To install MongoDB it all depends which Operating System you are using at the moment. But you can look up on google: "Install MongoDB MacOSX/Window/Ubuntu/etc.." and normally is just one simple command. To connect to it in your local you don't need a user or anything I guess.

How Do I Set Up The MEAN (Mongo, Express, Angular & Node) stack on Nitrous.IO

I using the upcoming weekend to check two things off of my 2013 project list:
Give Cloud Development A Try
Try ANGULAR.JS
My game plan is to set up the MEAN stack on Nitrous.IO and then use the stack to complete one of the many Angularjs tutorial projects available online.
Questions:
I'd be interested in hearing if anyone has set up the MEAN stack on Nitrous or otherwise or if anyone is aware of any good blog post that go through the process for someone with little to no javascript development experience.
Also, if you have setup a MEAN stack are there any things you would do differently or are there any invaluable resources I should be aware of.
Some Resources I Found Useful:
I've been researching online for the past week and have uncovered some great resources, but it would be great to see what others have found or can suggest. Below are some links to some resources that I have come across that may be helpful to others:
Building Angular Start-up Stack - Toronto Meetup Stream
Egghead.io Offers some great Video tutorials on Angular
Google's Angular site has a wealth of info.
USC Linux User Group Youtube video on MEAN on Amazon AWS
Thanks in advance for any resources, insights or guidance.
Since you are starting on JavaScript I would suggest that you start simple. For example
Build a simple web site with Node.js and Express (no Angular, no Mongo).
Deploy it to the cloud.
Then add Angular and see how the structure changes when you use an MVC framework on the client side (e.g. your backend becomes a plain REST API).
Then, play with Node.js and Mongo probably outside your simple Node/Express/Angular app to get the hand of a NoSQL database and database access from Node.js (the fact that everything is async brings some interesting challenges for beginners)
Then integrate Mongo into your app.
Ok, here's how I successfully set-up the MEAN stack on Nitrous.IO.
First, many thanks to Valeri V. Karpov and his The Code Barbarian blog. In July he had a blog post titled Introduction to the MEAN Stack, Part One: Setting Up Your Tools. I primarily followed his article, only making adjustment dictated by the Nitrous cloud platform.
So here are the steps:
Create A Nitrous Box: Go to the Nitrous site and sign-up for an account. Please note the free account does not provide enough storage to accommodate the full MEAN Stack. You'll need at least a "Start" pricing plan - at $9.99 per month.
Create A Nodejs Box: Once you complete your registration and select a pricing plan, its time to create a Nodejs box. Follow the instructions on the Nitrous site. The box comes preconfigured Nodejs.
Install Mongodb: To install Mongodb on your box, go to the shell prompt and type: parts install mongodb You can confirm the installation was successful by typing parts start mongodb. To stop the mongodb server you type parts stop mongodb.
Confirm your Node & NPM Installations: Type node at the command prompt. You should see a > sign if node is installed correctly. You are now in the node shell. Type control-c to exit the shell. Type NPM at the prompt and you should see some usage information
Install Express: type npm install express -g The -g flag means the package will be installed so you can run it from the terminal. Note, if you are using the free box you will likely encounter errors during the Express installation as a result of you exceeded the allocated storage.
From here on you can follow Valeri's article at Step 4 Creating an ExpressJS application..
Good luck and enjoy.
Use Bitnami https://bitnami.com/stack/mean. I like it a lot, pretty simple and concise. In my case it was for Windows and it was a seamless experience

Resources