Beispiel #1
0
 public static void hashPasswords() {
   List<User> users = User.findAll();
   for (User u : users) {
     u.password = Crypto.passwordHash(u.password);
     u.save();
   }
 }
Beispiel #2
0
  public static void initFriends() {
    List<User> users = User.findAll();
    for (User u : users) {
      u.friends.add(u);
      u.save();
    }
    User bob = User.findById(2L);
    User alice = User.findById(3L);
    User jeff = User.findById(4L);

    bob.friends.add(jeff);
    alice.friends.add(jeff);
    jeff.friends.add(bob);
    jeff.friends.add(alice);
    jeff.save();
  }