0
您好林在GreenDao我真的喜歡它,但我試着去建立一個信息新plataform使用Django REST API和Retrfit與GreenDao實體和我都來自該服務器的此JSON消息:GreenDao實體屬性
{
id: 1
created_at: "2015-10-06T02:45:48Z"
subject: "First message"
message: "Here is our first message across the messaging system! I feel just like Samuel Morse."
read: true
sender: {
url: "https://app.herokuapp.com/api/users/461"
username: "travis"
email: ""
is_staff: false
}
receiver: 81
}
問題是我怎麼可以把消息對象內部的綠色道「發件人」爲用戶對象不是字符串或長的物體Message對象內:
Schema schema = new Schema(DB_VERSION, ANDROID_APP_ID);
Entity privateMessage = schema.addEntity("PrivateMessage");
PropertyType user = schema.addEntity("User");
Property sender = privateMessage.addProperty(user., propertyName)
privateMessage.addStringProperty("id").primaryKey().unique();
privateMessage.addBooleanProperty("read");
privateMessage.addStringProperty("message");
user.addStringProperty("urlId").primaryKey().unique();
user.addStringProperty("url").unique();
user.addStringProperty("first_name");
user.addStringProperty("last_name");
user.addStringProperty("username").unique();
user.addStringProperty("email").unique();
user.addStringProperty("address");
user.addStringProperty("phone_number");
user.addStringProperty("password");
user.addStringProperty("group");
user.addBooleanProperty("sex");
user.addBooleanProperty("is_stuff");
user.addBooleanProperty("is_active");
user.addStringProperty("token");
user.addStringProperty("profile_picture");
user.addStringProperty("description");
user.addDateProperty("dob");
Property messagesThreatsId = privateMessage.addStringProperty("receiver").getProperty();
ToMany userToMessages = user.addToMany(privateMessage, messagesThreatsId);
Property conversations = privateMessage.addStringProperty("subject").getProperty();
Property created_at = privateMessage.addDateProperty("created_at").getProperty();
userToMessages.setName("LastMessages");
userToMessages.orderDesc(created_at);
http://stackoverflow.com/questions/13032987/greendao-support-multiple-relations-between-tables – Ivor