I have a domain class
class UserProfile {
List<String> interests = [];
ObjectId id;
String username;
String password;
String email;
static constraints = {
}
}
which is properly persisted in mongodb by gorm
def user = new UserProfile(username:"name",password:"pass",email:"asd@asd.com",interests: ['women','dogfight']);
user.save()
which could be verified in mongo console:
{ "_id" : ObjectId("528fd78003646357efb421c0"), "email" : "asd@asd.com", "interests" : [ "women", "dogfight"], "password" : "pass", "username" : "name", "version" : 0 }
so i get this object by
UserProfile.find() as JSON
in controller and got
{"class":"domain.users.UserProfile","id":{"class":"org.bson.types.ObjectId","inc":-273407552,"machine":56910679,"new":false,"time":1385158528000,"timeSecond":1385158528},"email":"asd\u0040asd.com","password":"pass","username":"name"}
as you can see list of interests unfortunately was not rendered
I would appreciate any help. Thanx.
P.S. Grails v2.3.3
Specifying association in domain class should help.
static hasMany = [interests: String]