Skip to content

⬆ Update

Gustavo M. Paes edited this page Dec 10, 2021 · 1 revision

Update data

To update a data from mysql table, using this class as a example:

	public class User extends WormTable {
		@WormField(sqlType = "VARCHAR", length = 36, idColumn = true)
		String userUuid;
		@WormField(sqlType = "VARCHAR", length = 50)
		String name;
		@WormField(sqlType = "VARCHAR", length = 50, nullable = true, defaultValue = "NULL")
		String email;

		public User(){}
		public User(String userUuid, String name, String email){
			this.userUuid = userUuid;
			this.name = name;
			this.email = email;
		}
	}

to update a data just use Update() method:

	User user = new User();
	user.Get('88e5bccd-0b36-47bd-ad21-3c41efce899e');
	user.name = "Gampe";
	user.Update();

Update() will get the data with this where into Mysql table and return a boolean, if is true is successful updated and if is false was a error.


Update more than one data

to update a data just use Update() method with where:

	User user = new User();
	user.Get('88e5bccd-0b36-47bd-ad21-3c41efce899e');
	user.name = "Gampe";
	user.Update('name like "%G"');

will update all data that satisfact this where


Clone this wiki locally