0
データストアのpythonバージョンにはget_or_insert()メソッドがあります。 Objectifyは同様のものを提供していますか?オブジェクト化にはget_or_insertの同等物があります
データストアのpythonバージョンにはget_or_insert()メソッドがあります。 Objectifyは同様のものを提供していますか?オブジェクト化にはget_or_insertの同等物があります
残念ながらObjectifyにはこのような機能はありません。しかし、あなた自身で同様のものを実装することができます。
public Something getOrInsert(Something s) {
return ofy().transact(new Work<Something>() {
public Something run() {
Something something = ofy().load().type(Something.class).id(s.getId()).now();
if(something != null) {
return something;
}
ofy().save().entity(s);
return s;
}
});
}