 sqlHelper = require './sqlHelper'
 
 class QueryBuilder
-  constructor: (@table, @dbConnection) ->
+  constructor: (@table, @dbConnection, @idColumn) ->
     @query = ""
     @returnArray = true
 

    else
      @

  findByIdAndUpdate: (id, update, options, cb) ->
    @returnArray = false
    @query = 'SELECT TOP 1 * FROM ' + @table + ' WHERE _id = ' + id
    if cb?
      @exec cb
    else
      @

  remove: (query, cb) ->
    @returnArray = false

  if def.options?.collectionName?
    collectionName = def.options.collectionName

  idColumn = "_id"
  if def.options?.idColumn?
    idColumn = def.options.idColumn

  qb = new def.Qb(collectionName, dbConnection, idColumn)
  qb.modelName = def.name
  qb

