我有一个Mongo集合,其中包含一个包含prio属性的数组。
@Entity
@Table(name = "users")
public class User {
@Id
@GeneratedValue
@Column(name = "f_id")
private int id;
@Column(name = "f_login")
private String login;
@Column(name = "f_password")
private String password;
@OneToOne(mappedBy = "user", cascade = CascadeType.ALL)
private Compte compte;
}
@Entity
@Table(name = "comptes")
public class Compte {
@Id
@GeneratedValue
@Column(name = "f_id")
private int id;
@OneToOne
@JoinColumn(name = "fk_user")
private User user;
@Column(name = "f_name")
private String name;
}
e.g。当我想删除第二个元素时,我的数组将是[prio:1,prio:3]
那么在Mongo中是否有办法以某种方式自动订购prio? 结果应该是:[prio:1,prio:2]
否则我会读取集合并在我的应用程序中手动更新整个数组。