hasAttribute method

bool hasAttribute(
  1. String column
)
inherited

Checks if an attribute exists in the attribute map.

Returns true if the attribute has been set, even if its value is null. Returns false if the attribute has never been set or if attribute tracking is not initialized (e.g., on plain model instances not managed by the ORM).

Note: This only works on ORM-managed model instances (those created by queries or with attribute tracking properly initialized).

Example:

final user = await Users.query().where('id', 1).first();
print(user.hasAttribute('email')); // true
print(user.hasAttribute('nonexistent')); // false

Implementation

bool hasAttribute(String column) {
  final attrs = _store[this];
  return attrs != null && attrs.containsKey(column);
}