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
//Author: Engin Kartal | |
//Blog Post: http://enginkartal.com.tr/mongodb-find/ | |
//bu metod tüm dokümanları getirir. | |
db.collection.find({}) | |
//SQL | |
select * from table | |
//bu metod geriye tek doküman döndürür. |
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
//content.json | |
{ | |
_id:ObjectId("507f191e810c19729de860ea"), | |
title: 'MongoDB Insert', | |
description: 'MongoDB Kayıt ekleme', | |
author: 'Engin Kartal', | |
url: 'http://www.enginkartal.com.tr', | |
keywors: ['mongodb', 'database', 'insert'], | |
likes: 5, |
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
//bu query likes sayısı 5 eşit olan dökümanları getirir. | |
db.collection.find({likes:5}) | |
//Sonuç | |
{ | |
_id:ObjectId("507f191e810c19729de860ea"), | |
title: 'MongoDB Insert', | |
description: 'MongoDB Kayıt ekleme', | |
author: 'Engin Kartal', | |
url: 'http://www.enginkartal.com.tr', |
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
//Bu şekilde kullanıldığında sonuç görüntüsü kolay okunabilir bir format halini geliyor. | |
db.collection.find(<koşul>).pretty() |
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
//aşağıdaki şekilde author küçükten büyüğe indexlenir. | |
db.content.createIndex("author":1) | |
//aşağıdaki şekilde ise author büyükten küçüğe indexlenir. | |
db.content.createIndex("author":-1) |
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
//content dokümanındaki tüm 'url' fiedlarının adını link olarak değiştiriyoruz. | |
db.content.update({},{$rename:{'url':'link'}},false,true) |
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
//Author: Engin Kartal | |
//Blog Post: http://enginkartal.com.tr/mongodb-karsilastirma-operatorleri/ | |
//eq operatörü :: Eşittir | |
//Aşağıdaki sorgu bize geri "likes" sayısı 7'ye eşit olanları döner. | |
db.content.find({likes:{$eq:7}}) | |
//ne(not equal) operatörü :: Eşit Değildir. | |
//Aşağıdaki sorgu bize geri "author"u "Engin Kartal"'a eşit olmayan kayıtları döner. | |
db.content.find({author:{$ne:'Engin Kartal'}}) |
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
//Author: Engin Kartal | |
//Blog Post: http://enginkartal.com.tr/mongodb-mantiksal-logical-operatorler/ | |
//AND operatörü | |
//Aşağıdaki sorgu bize geri author="Engin Kartal" ve "likes" sayısı 5'e eşit olan kayıtları döner. | |
db.content.find({$and:[{author:'Engin Kartal'},{likes:5}]) | |
//author="Engin Kartal" ve "likes" sayısı 10'dan az olan kayıtlar | |
db.content.find({$and:[{author:{$eq:'Engin Kartal'}},{likes:{$lt:10}}]) | |
//OR operatörü |
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
//Author: Engin Kartal | |
//Blog Post: http://enginkartal.com.tr/mongodb-remove/ | |
db.collection.remove( | |
<query>, | |
{ | |
justOne: <boolean>, | |
writeConcern: <document> | |
} | |
) |
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
server { | |
listen 80; | |
root /usr/share/nginx/html/laravel/public; | |
index index.php index.html index.htm; | |
server_name laravel.dev; | |
location / { | |
try_files $uri $uri/ /index.php?$query_string; |
OlderNewer