# How to project a subset of properties?

  1. Inorder to project a subset of properties in a collection while reading from the data-base, define the subset as a selection inside the collection definition in .kmongo.

    For example, to read only the name & designation:







     


    collection Employee {
    	property name:String
    	property designation:String
    	property dob:CalendarDate
    	...
    	
    	selection BasicInfo (name, designation)
    }
    
  2. run command compile

  3. Use the respective find<SelectionName> to read the projected fields from the database.

Sample Usage:


 



def getEmployeesForDesignation(desig: String): List[String] = {
    val empRowList = EmployeeQuery().designation.is(desig).findBasicInfo
    empRowList.map(x => x.name)
}