npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nodejs-ejsli-veritabanli-modelmigrationlu-hazir-proje-yapisi

v1.0.0

Published

"**EĞER PROJE OLUŞTURACAKSAN NODE JS İLE SERVERİ OLAN: DİREK 'NODEJS_passportJS_mailGonderme_facebooklaGiris' VEYA 'NODEJS_arayuzlu_detayli_web_projesi' klasör yapısını, app.js içeriğiyle beraber ve layout için index.ejs yapısıyla beraber sadece içerik

Downloads

4

Readme

"**EĞER PROJE OLUŞTURACAKSAN NODE JS İLE SERVERİ OLAN: DİREK 'NODEJS_passportJS_mailGonderme_facebooklaGiris' VEYA 'NODEJS_arayuzlu_detayli_web_projesi' klasör yapısını, app.js içeriğiyle beraber ve layout için index.ejs yapısıyla beraber sadece içerikleri silip app.js vs içeriklerine ve kullanacağın içeriklere karışmadan bu yapıyı kopyalayıp kullanabilirsin.

YADA BU YAPINI NPM KÜTÜPHANESİNE GİRİŞ YAPIP ORAYA KENDİNE ÖZEL YADA HALKA AÇIK ŞEKİLDE APP.JS, CONFİG DOSYALARI vs GİBİ ÖNEMLİ AYARLARI DEĞİŞTİRMEDEN YÜKLE.

YENİ PROJE OLUŞTURACAĞIN ZAMAN BU HAZIR YAPINI DİREK ÇAĞIRIP İÇERİKLERİ DEĞİŞTİRİP BAŞTAN YAZMADAN KLASÖRLERİ AYARLARINI VS DİREK KULLANABİLİRSİN İSTEDİĞİN YERİNİ DEĞİŞTİRİP..."

"BU MODÜL İLE VE DİĞER PROJE YAPISI MODÜLLERİ İLE BASTAN PORJE DOSYA KLASÖR VS ŞEYLERİ OLUŞTURMADAN MODÜLÜ NPM İ İLE ADIYLA İNSTALL EDİP HAZIR KLASÖR YAPISINI VE AYARLARINI KULLANIP PROJE OLUŞTURMADA ZAMAN KAZANABİLİRSİN!!!"

"--------------------------------------------------------------------------" "VERİTABANI BAGLANTISI" "Burada config klasörü veritabanı bilgilerini gireceğimiz yerdir. migrations klasörü veritabanı ile nesneler arasında senkronizasyonu yapacağımız kısımdır. seeders klasörü toplu veritabanı işlemlerini yaptığımız kısımdır. models klasörü veritabanında tablolara karşılık gelen javascript nesnelerimizin olduğu kısımdır. Burada oluşan index.js modellerimizin yönetildiği database context’ine karşılık gelmektedir. Burada modeller context üzerinde işlenir ve modellere erişim yine bu context üzerinden sağlanmaktadır.

1-)config klasörü içindeki config.json dosyasına kendi veritabanı bağlantı bilgilerini ekle

2-)**yandaki terminaline: sequelize-cli model:generate --name MODELADIN --attributes ad:string,kullaniciadi:string,yas:integer

bu kodu çalıştırırsan "--name" etiketinden sonra model adını verirsin,"--attributes" den sonra tablo sutunlarını verirsin.created at ve updated at otomatik oluşur ve doldurulur.

model klasöründe verdiğin adla modelin oluşmuş olur. migration klasöründe oluşturacağın tablo ve yapısı oluşmuş olur.

3-)**yandaki terminaline: sequelize-cli db:migrate

çalıştırırsan users tablon oluşur veritabanında migration yapısına uygun olarak"


4-)ARTIK MODEL VE MİGRATİON YAPIN YAZIR VE VERİTABANI BAĞLANTIN VAR. AŞAĞIDAKİ KODLARI GET,PUT,POST,DELETE isteklerine yazıp işlemlerini yapabilirsin.

const router=require('express').Router(); ///const dbConnection=require("../db/dbConnection"); const model = require('../models')

router.get('/', (istek,cevap)=>{ console.log("get calisti") /*dbConnection.query("select * from users", (err, rows, fields) => { if (err) throw err

    console.log(rows);
});*/

const users=model.users.findAll().then((rows)=>{
    rows.forEach(row => {
        console.log(row.dataValues);
    });
});


cevap.status(200).json({'mesaj':'hosgeldiniz...'});

}); router.get('/:id', (istek,cevap)=>{ console.log(istek.query.sortBy) //isteğe bağlı gelen parametreyi json olarak verir ({'sortBy':'name'} gibi) const users=model.users.findOne({where:{id:istek.params.id}}).then((row)=>{ console.log(row.dataValues); }); cevap.status(200).json(istek.params.id); });

router.post('/', (istek,cevap)=>{ console.log('post calisti'); console.log(istek.body) const user=model.users.build({ ad:istek.body.isim, yas:istek.body.yas, kullaniciadi:istek.body.userName, }); user.save().then((rows)=>{console.log("kayıt basarili")}).catch(()=>{console.log("kayıt yapılamadi")}); cevap.status(200).json(istek.body); });

router.patch('/:id', (istek,cevap)=>{ console.log(istek.params.id+ 'id li düzenlenecek') const user=model.users.update({ ad:istek.body.isim, yas:istek.body.yas, kullaniciadi:istek.body.userName, },{ where:{ id:istek.params.id } }

).then((rows)=>{console.log("guncelleme basarili")}).catch(()=>{console.log("guncelleme yapılamadi")});
cevap.status(200).json(istek.body);

});

router.delete('/:id', (istek,cevap)=>{ console.log(istek.params.id+ 'id li silinecek') const user=model.users.destroy({ where:{ id:istek.params.id, } }).then((rows)=>{console.log("silme basarili")}).catch(()=>{console.log("silme yapılamadi")});

});

module.exports=router;