Skip to content

❌ Delete

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

Delete data

To delete 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 delete a data just use Delete() method:

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

Delete() will get the data with into Mysql table and return a boolean, if is true is successful deleted and if is false was a error.


Delete more than one data

to delete a data just use Delete() method with where:

	User user = new User();
	user.Delete("name like '%g'");

will delete all data that satisfact this where


Clone this wiki locally