src/main/scala/fis/aaa/model/AaaSchema.scala
author Tomas Zeman <tzeman@volny.cz>
Fri, 20 Apr 2012 08:26:22 +0200
changeset 61 b65843860274
parent 56 9409e7ab3f9d
child 73 4bcb7deedd3f
permissions -rw-r--r--
Trackable entity: created/updated fields

/*
 * Copyright 2011-2012 Tomas Zeman <tzeman@volny.cz>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package fis.aaa.model

import fis.base.model.BaseSchema
import net.liftweb.squerylrecord.RecordTypeMode._

/**
 * Database schema for users, ...
 */
trait AaaSchema extends BaseSchema {
  val userT = tableWithSeq[User]
  on(userT)(t => declare(
    t.login   defineAs(indexed("user_login_idx")),
    columns(t.deleted, t.active) are(indexed("user_deleted_active_idx"))
  ))

  UserVendors.byId.default.set(UserCrud.get _)

  /** All existing (undeleted) users. */
  val usersF = () => from(userT)(u =>
    where(u.deleted === false) select(u) orderBy(u.name asc))

  /** Active users. */
  val activeUsersF = () => from(userT)(u =>
    where(u.deleted === false and u.active === true) select(u)
    orderBy(u.name asc))
}

object AaaSchema extends AaaSchema

// vim: set ts=2 sw=2 et: