Skip to content

Use thrift as IDL and (will support scrooge -> mongodb as first step)

Notifications You must be signed in to change notification settings

lambdalab/thriftdao

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

81 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

thriftdao

Build Status

Use thrift as IDL and dao (Now only support scrooge -> mongodb)

Usage: assume you defined as thrift file:

struct Name {
  1: string firstName
  2: string lastName
  3: optional string nickName
}

struct Person {
  1: Name name
  2: i32 age
}

After you use scrooge to generated the file, you could then declare a schema like:

object TestSchemas extends Schemas {
  apply(
    Person -> create(Person) (
      primaryKey = List(_.NameField), // Primary key will be unique indexed by default
      indexes = List(
        Index("Age"/*index name*/, false /*non unique*/, List(_.NationalityField) /*fields to be indexed*/)
      )
    )
  )
}

Now you could get a DAO object by doing

val dao = TestSchemas(Person).connect(db /* mongodb instance */)

Now you could do varies data operations, such as:

dao.findOne(Person.AgeField -> 14)
dao.findNested(List(Person.nameField, Name.firstNameField) -> "Philip")

you could to update and remove as well

About

Use thrift as IDL and (will support scrooge -> mongodb as first step)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •