I want to load test data in my scala play application from data.yml file
which is in YAML format.
My entities looks like:
@Entity("users")
User(@Required val uname: String, val isAdmin: Boolean = false) {
@Id var id: ObjectId = _
@Reference val accounts = new ArrayList[Account]
}
@Entity("account")
class Account {
@Id var id: ObjectId = _
@Embedded val addresses = new ArrayList[Address]
@Reference val departments = new ArrayList[Department]
var description : String = _
}
class Address {
street: String = _
city: String = _
}
@Entity("department")
class Department {
@Id var id: ObjectId = _
principal: String = _
}
This is what almost a blank data.yml look like:
User(foo):
uname: Foo
accounts:
I want to load one user with 2 accounts. One of the account has just one address and one department, the other account has 2 addresses and one department to keep things as simple as possible. So what the complete yml data looks to achieve this?
Why can’t you just use lists with keys? Using the ‘- key’ notation or ‘[key1, key2]’? Example:
Check http://en.wikipedia.org/wiki/Yaml#Lists