This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -XPOST http://localhost:9200/my/terms/_search?pretty=true -d ' | |
{ | |
"query" : { "wildcard" : {"term" : "fire"} }, | |
"facets" : { | |
"langs" : { "terms" : {"field" : "translations.lang"} } | |
} | |
} | |
' | |
Result: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Non-blocking | |
Burada kullanıcı ve yorum bilgilerinin veritabanından alınması | |
beklenmeden sıradaki kod çalıştırılıyor | |
**/ | |
console.log("Kullanıcı bilgileri alınıyor...") | |
User.findOne({username: "johndoe"}, function(err, userName) { | |
console.log("Kullanıcı bulundu: " + userName); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Blocking | |
Burada işlem 7.satır bitmeden 8'e, 11. satır bitmeden 12. satıra geçmeyecektir | |
**/ | |
console.log("Kullanıcı bilgileri alınıyor...") | |
var user = User.findOne({username: "johndoe"}); | |
console.log("Kullanıcı bulundu: " + user); | |
console.log("Kullanıcı yorumları alınıyor...") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Gerekli modüller yükleniyor. MVC web projesi için 'express', db için 'mongodb', | |
* çeşitli ayarları yazıp okuyabilmek için 'config', kendi helper fonksiyonlarımız | |
* için 'utils', ... | |
*/ | |
// Module initializations | |
var express = require('express') | |
, http = require('http') | |
, path = require('path') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var OAuth = require('OAuth'); | |
var oauth = new OAuth.OAuth( | |
'https://api.twitter.com/oauth/request_token', | |
'https://api.twitter.com/oauth/access_token', | |
'your Twitter application consumer key', | |
'your Twitter application secret', | |
'1.0A', | |
null, | |
'HMAC-SHA1' | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Model parametre olarak mongoose objesi alıyor | |
* ve bu mongoose objesi app.js içinde modeller | |
* tanımlanırken atanıyor. | |
*/ | |
module.exports = function (mongoose) { | |
var validator = require('../lib/validator'), | |
Schema = mongoose.Schema, | |
util = require('util'), | |
config = require('config'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Yine mongoose objesini parametre olarak alıp | |
* modelimizi tanımlamaya başlıyoruz | |
*/ | |
module.exports = function (mongoose) { | |
var validator = require('../lib/validator'), | |
Schema = mongoose.Schema, | |
util = require('util'), | |
config = require('config'), | |
Blog, Comment; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Kullanıcı dataları formdan geldi ve bunları aldık | |
* Yeni bir User Objesi yaratıp aldığımız dataları | |
* bu modele kaydettik. Sonra kaydet fonksiyonunu çağırıp | |
* Hata olup olmadığını kontrol ettik | |
*/ | |
var email = req.body.email; | |
var password = req.body.password; | |
var username = email.split("@"); | |
username = username[0]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var util = require('util'); | |
var Logger = require('devnull'); | |
var logger = new Logger({namespacing : 0}); | |
var User = require('../models/User'); | |
var crypto = require('crypto'); | |
UserController = function (app, mongoose, config) { | |
var User = mongoose.model('User'); | |
/** | |
* Kullanıcı login işlemi için bu fonksiyona gelecektir. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var util = require('util'); | |
var Logger = require('devnull'); | |
var logger = new Logger({namespacing : 0}); | |
var Blog = require('../models/Blog'); | |
/** | |
* Gerekli modelimiz olan Blog modelini tanımladık, controller | |
* içinde kullanılmaya hazır | |
*/ | |
BlogController = function (app, mongoose, config) { | |
// Yukarıda tanımladığımız Blog modelinin bir referansını burada tanımlıyoruz |
OlderNewer