Repository is the base class of all kind of persistance processes. It offers the base CRUD services to save (add/update), find and delete instances.
Instances are stored in their serialized form. See the serialization
package
for more documentation.
popcorn :: Repository :: defaultinit
popcorn :: Repository :: deserialize
Deserialize astring
to an instance.
popcorn :: Repository :: find_by_id
Find an instance by it'sid
popcorn :: Repository :: remove_all
Remove all the instances matching onquery
popcorn :: Repository :: remove_by_id
Remove the instance withid
popcorn $ Repository :: SELF
Type of this instance, automatically specialized in every classcore :: Object :: class_factory
Implementation used byget_class
to create the specific class.
popcorn :: Repository :: defaultinit
core :: Object :: defaultinit
popcorn :: Repository :: deserialize
Deserialize astring
to an instance.
popcorn :: Repository :: find_by_id
Find an instance by it'sid
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
core :: Object :: output_class_name
Display class name on stdout (debug only).popcorn :: Repository :: remove_all
Remove all the instances matching onquery
popcorn :: Repository :: remove_by_id
Remove the instance withid
github :: BranchRepo
github :: CommitRepo
# A Repository is an object that can store serialized instances.
#
# Repository is the base class of all kind of persistance processes. It offers
# the base CRUD services to save (add/update), find and delete instances.
#
# Instances are stored in their serialized form. See the `serialization` package
# for more documentation.
interface Repository[E: Serializable]
# Kind of queries accepted
#
# Can be redefined to accept more precise queries depending on the backend used.
type QUERY: RepositoryQuery
# Find an instance by it's `id`
#
# `id` is an abstract thing at this stage
# TODO maybe introduce the `PrimaryKey` concept?
fun find_by_id(id: String): nullable E is abstract
# Find an instance based on `query`
fun find(query: QUERY): nullable E is abstract
# Find all instances based on `query`
#
# Using `query` == null will retrieve all the document in the repository.
fun find_all(query: nullable QUERY, skip, limit: nullable Int): Array[E] is abstract
# Count instances that matches `query`
fun count(query: nullable QUERY): Int is abstract
# Save an `instance`
fun save(instance: E): Bool is abstract
# Remove the instance with `id`
fun remove_by_id(id: String): Bool is abstract
# Remove the instance based on `query`
fun remove(query: nullable QUERY): Bool is abstract
# Remove all the instances matching on `query`
fun remove_all(query: nullable QUERY): Bool is abstract
# Remove all instances
fun clear: Bool is abstract
# Serialize an `instance` to a String.
fun serialize(instance: nullable E): nullable String is abstract
# Deserialize a `string` to an instance.
fun deserialize(string: nullable String): nullable E is abstract
end
lib/popcorn/pop_repos.nit:158,1--209,3