Skip to main content

Posts

Showing posts from October, 2012

Using MongoDB Scala $nin

Hi guys, Today I needed to execute a query to filter some records. Lets say I have a Product Collection(Tables are called Collection in MongoDB) and I have following two fields in my product collection for simplicity. Product ---------------- Id sku (store keeping unit) I retrieve data from collection like this. var products = models.Product.find(MongoDBObject("title" -> "atitle") ) .skip(0).limit(10).toList I have filtered data by 'title' already and I have I want 10 records from 0 by specifying skip and limit. Now I have another list ('sku' list) that is list contains sku values. I want to retrieve Product list from DB that is not in SKU list. To do this I have used $nin which is a query operator of MongoDB. var products = models.Product.find( {"sku" $nin descendents}, {MongoDBObject("title" -> "atitle")} ) .skip(offest).limit(10).toList more...

How to save Large html(data) content with Play framewrok, MongoDB and Scala

Hi all, While I was working on a project I had to save large content of data from text area filed in a form. I'm using Play Framework 2.0.2 as a web framework and using scala html templates as views. I have text area filed in my form to add html data (Actually here I'm using ace.js   that is high quality code editor. Ill give brief introduction to ace later). Ok Here I do not post form binding with model class but just think that there is a simple model class lets say Page. Most important thing is the saving part of this program. Here I have posted my save definition(function). def save = Action(parse.urlFormEncoded(maxLength = 1024 * 1000))  { implicit request =           //More code goes here.. I have not posted           Page.save(pageForm)           Redirect(Pages.show(        ...