Some WEB Tricks

If You Want to put The Content Of A Wrapper Center Of The Page Just Add

margin:0 , auto;
max-width

------------------------------------------------------------------------------------------------------------------

process.env.port,process.env.IP,

fiverrstudent job,

appp.get("*", function(req,res){
// for 404 Error
})

In routes Order Matters

appp.get("/r/:partern", function(req,res)

(:) if you put it it become a variable of this like

express req hold a lot of data  example - req.params

express docs
---------------------------------------------------------------------------------------------------------------------------------

in ejs there are two tags

<%= %> if you want to print (the result of the logic) after logic
<% %> if you just want the logic
--------------------------------------------
express -- var/let (which is the variable is put to the left and what we call in the ejs tamplate  it was put to the right);
{posts : posts}
----------------------------------------------------------------
loop in ejs for(var i=0; i < posts.length; i++)
--------------------------------------------------------------------------
css not working in ejs  [by default not serve anything without views]

app.use(express.static("public"))
--------------------------------------------------------------------------------
set view engine
----------------------------------------------
partials
-------------------------------------------------------
/app.css,- outside of the main directoty

app.css -in side the main derectory
-------------------------------------------------------------------
====================================================================

body-parser extract data from the from to the server side
body-parse docs
-----------------------------------------
req.body.<name in form>
----------------------------------------------
res.render/send/redirect
=========================================
Rest conventation get /friens see the list
 post /friends mutate the DB
/friends/new show the form

----------------------------------------------------------------------------------------------------------------------
mongo command
mongod
mongo
help
show dbs (show all dbs)
use (make a db and use it)
insert (insert data) [create]
find (find data) [read]
update
remove
-------------------------------------------
Nosql -only name , all, empty
 db.dogs.insert()
dbname.collectionsname.method()
------------------------------------------------------
restful routes
INDEX        /friends                GET  Display the list of dogs
NEW           /firends/new      GET form to make a new friend
CREATE    /friends                POST Add new dog to db
SHOW      /friends/:id            GET   show info about one dog
 -------------------------------------------------------------------------
methods starts with lower case
----------------------------------------
REST - restfull routes 7 different routes

----------------------------------------------------------------------------------------------------------------------------------

delete request                                         action="/blogs/<%= blog._id %>?_method=DELETE" method="POST"
findByIdAndRemove(req.params.id, function(err){
if(err){
res.redirect("/blogs")
}
})


redoit
------------------------------------------------------------------------------------------------------------------------
Associations  : its the relationship and there are one:one , one:many, Many: Many relaionship
we do it by   1  Embeding Data,
                              2 Referencing Data


-----------------------------------------------------------------------------------------------------------------------
if you want your form to submit add name attribute to every input field

How passport work in node.js and express
--------------------------------Code To rename UploadedFile In php
$filename=str_replace('.','-',basename($filename,$ext));
$newfilename=$filename.time().".".$ext; move_uploaded_file($filename_tmp, 'images/'.$newfilename); 
$finalimg=$newfilename;
























No comments:

Post a Comment