Tags » Mongo

Membuat Pagination di Flask + MongoDB

Pertama, kita butuh flask extension yang bernama flask-paginate

https://pythonhosted.org/Flask-paginate/

Kemudian tambahkan baris berikut di route yang mau di-paginasi, misal search result:

from flask_paginate import Pagination, get_page_parameter

@app.route("/search/<keyword>")
def search(keyword):
	page = request.args.get(get_page_parameter(), type=int, default=1)
	per_page = 3
	offset = (page - 1) * per_page
	data = db.product.find({'$text': {'$search': keyword}}, {'score':
		{'$meta':
		'textScore'}}).sort([('score', {'$meta': 'textScore'})]).skip(offset).limit(per_page)

	pagination = Pagination(page=page,
		per_page=per_page,
		total=data.count(),
		css_framework='bootstrap3',
		search=False,
		record_name='products')

	keyword_title = keyword.replace('-', ' ').title()
	return render_template("search.html",
		keyword_title=keyword_title,
		data=data,
		pagination=pagination
	) 46 more words
Flask

Installing MongoDB Server on Local LAN

Today I got hold  of an old HP laptop, alongside  an old compaq laptop that had aged out. The HP had still life on it running on Elementary OS with 500 MB RAM (very old, yet smooth so kudos Elementary), so I removed RAM from my compaq and increased Dell RAM to 1 GB… 200 more words

From 0's And 1's

How to easily find slow queries at MongoDB

Enable profiling

First, you have to enable profiling.

> db.setProfilingLevel(1)

Now let it run for a while. It collects the slow queries ( > 100ms) into a capped collections, so queries go in and if it’s full, old queries go out, so don’t be surprised that it’s a moving target. 37 more words

MongoDB Shell Functions - Can we customize ?

While working on MongoDB, I accidentally ran a find() count query incorrectly which resulted in something interesting.

While I wanted to execute db.team.find().count(), I ended up hitting enter key a bit too sooner and resultant query in the mongo shell was  207 more words

#mongodb #nosql

Five Mongo Commands you must know

Once you have connected to mongod in your environment through mongo shell. You want to know about the databases or may be all collection in a particular database. 244 more words

Intro

#138 Daily Dose : Convert your MySQL to MongoDB

http://www.querymongo.com/

Never worry about MongoDB syntax again.

Stitch connects to MongoDB, along with all the other data sources your business uses, and streams that data to Amazon Redshift.

24 more words
Daily Dose

MongoDB mapreduce Introduction

What is Map-reduce ?

Map-reduce is a programming model that helps to do operations on big data in parallel to achieve faster results. To understand map reduce go through… 937 more words

Mapreduce