I'm working on learning node.js as a possible tool for web development. I understand how express.js works, but I'm not sure how to integrate mongoose models, I've tried searching google and here for an answer with no luck. Where should models go? Should they go in app.js, with the rest of the configuration and rorouting information? or should they go in a seperate file and imported like a normal module? Any information and resources would be appreciated. Thank you.
I would recommend putting your models in separate files even if just for code organisation purposes. Create them as normal node modules and export the schema. Import the schema into your app.js and model them there:
var ModelSchema = require('models/model');
var model = mongoose.model('Model', ModelSchema);
Related
Hi im not an advanced coder just a hobbyist with 1% javascript experience, only laravel and rubyrails.
I have build a admin dashboard with crud and everything in 100% laravel-8...
Now i want to replace all the crud tables i got with Vue.js.
Unfortunately i have found it to be quite confusing to understand. I see a lot of people be replacing there blade view with vue components and routes too. Can someone explain me the flow of the whole process of replacing and folder managing in vue?
If u know a good site that would be helpful too.
Please do not send orginal Vue documentation site, thank u.
I would suggest creating another project for the client side, for example, VueCli or NuxtJs. And use the Laravel project as a RestFull API that provides all the data needed in the client side.
That will provide you much more scalability, rather than having it all together in the Laravel project.
I am writing a web app in WebStorm based on GraphQL. The web app is comprised of two components (i.e. frontend and backend). On the backend, I am using makeExecutableSchema to create multiple schemas and then merging them together to help maintain my code.
The frontend relies on a WebStorm plugin called JS GraphQL that helps interpret GraphQL mutations and queries as described here. The plugin expects to see a .graphql file to understand typedefs. I can manually copy/paste information from the backend to the frontend directories. Ideally, I would automatically generate the .graphql file for the frontend during the backend coding. Does anyone have insight on how to accomplish this?
Have you looked into graphql-code-generator? It has a plugin architecture and so can be adapted to a variety of needs. I've been on teams that have used it successfully on a few projects, and it's not hard to hook up to CI or whatever.
I want to use a chart package to create a chart using real time data from my database. I tried a package.The link i am providing bellow.But i am not successful.Can anyone provide me a full tutorial about this ?
https://charts.erik.cat/getting_started.html#screenshots
If you want to use charts in your laravel app, I believe you will need to do this in blade view (frontend)
Here are very good JS chat libraries with good documentation
I am currently using
https://www.chartjs.org/
Another good one
http://morrisjs.github.io/morris.js/
Chart solely for laravel http://lavacharts.com
Check these examples on adminlte
https://adminlte.io/themes/AdminLTE/pages/charts/chartjs.html
Another thing, you will need to learn how to use their API. This is universal, everyone has to learn. However, there are a lot of examples you could extract and use as a baseline.
Hope This helped you.
I have to implement a ticket tool in several applications made with laravel, my question is, if there is any way to do this function in a module with its own routes to existing projects as it is done with angular modules, and to be as it would be. thanks and best regards
In laravel they called it a package instead of modules.
Just follow this laravel package development docs how to implement it.
https://laravel.com/docs/5.6/packages
What is the best way to use codeIgniter with BoilerplateJS? should I put the codeIgniter folder in a BoilerplateJS folder or the contrary? Or something else? Need to make an authentifcation page in codeigniter and redirect the application in boilerplateJS.
Thanks.
I tried BoilerplateJS with CI in the following way:
Basically this is including BoilerplateJS in CodeIgniter folder.
I included all the BoilerplateJS code except the index file in to a folder named public which is in the root folder of CodeIgniter. The index file is placed in the views folder and will be loaded by a controller. (See the image)
For this to work some file paths had to be tweaked.
File paths in boilerplatejs index file (boilerplate.html in my case) had to be changed as follows:
./libs/jquery/jquery-min.js >>to>> public/libs/jquery/jquery-min.js
./libs/underscore/underscore-1.3.3.js >>to>> public/libs/underscore/underscore-1.3.3.js
and so on.
In main.js requirejs path configurations should be changed to:
require.config({
//Let's define short alias for commonly used AMD libraries and name-spaces.
paths : {
// requirejs plugins in use
text : 'libs/require/text',
i18n : 'libs/require/i18n',
path : 'libs/require/path',
// namespace that aggregate core classes that are in frequent use
Boiler : './app/core/_boiler_'
}
});
And in your controller you can load boilerplatejs by: $this->load->view('boilerplate.html');
I was thinking of integrating BoilerplateJS and CodeIgniter and probably use codeignighter-rest server for some time.
If all goes well I will share the code within the week.
A sample project is available at: https://github.com/slayerjay/codeigniter-boilerplatejs
EDIT Adding my view on CodeIgniter and BoilerplateJS
Firstly I have not (yet) done any major projects with BoilerplateJS and Codeigniter. But I have done projects using CI and the CI REST Server and know BoilerplateJS in and out.
I do not have much experience with other PHP frameworks (I have meddled with cakePHP and some others) but for me CI helps me to organize my code according to MVC pattern in a clean way, and provides excellent helper libraries and documentation.
As the OP rightly said, authentication is handled best outside BoilerplateJS and this can be done nicely with something like ion-auth for CI. After the user is authenticated and the SPA is loaded, the rest of the calls will be handled by the CodeIgniter REST server.
In this case you won’t be using much of the View aspect of your MVC architecture, but CI’s models and helpers would be of great help.
If you just need a simple REST server you can go with some lightweight solution that just provides REST type routing, but in many cases you will need to interact with a database and do some data processing.
So if you have decided to have a PHP backend for your application, Codeigniter with the REST server is a good choice.