Get a new entity object by entity name. You can also pass in a structure called properties
that will be used to populate the new entity with or you can use optional named parameters to call setters within the new entity to have shorthand population.
This function returns the newly created entity
Key
Type
Required
Default
Description
entityName
any
true
---
properties
struct
false
{}
A structure of name-value pairs to populate the new entity with
composeRelationships
boolean
false
true
Automatically attempt to compose relationships from the incoming properties memento
nullEmptyInclude
string
false
---
A list of keys to NULL when empty
nullEmptyExclude
string
false
---
A list of keys to NOT NULL when empty
ignoreEmpty
boolean
false
false
Ignore empty property values on populations
include
string
false
---
A list of keys to include in the population from the incoming properties memento
exclude
string
false
---
A list of keys to exclude in the population from the incoming properties memento
Populate an entity with a structure of name-value pairs. Make sure the names of the properties match the keys in the structure.
This function returns the populated object
INFO With composeRelationships=true, you can populate one-to-many, many-to-one, many-to-many, and one-to-one relationships from property values in the memento. For 'many-to-one' and 'one-to-one' relationships, the value of the property in the memento should be a single value of the primary key of the target entity to be loaded. For 'one-to-many' and 'many-to-many' relationships, the value of the property in the memento should a comma-delimited list or array of the primary keys of the target entities to be loaded.
Key
Type
Required
Default
Description
target
any
Yes
---
The entity to populate
qry
query
Yes
---
The query to populate with
rowNumber
numeric
false
1
The row to use to populate with.
scope
string
No
---
Use scope injection instead of setter injection, no need of setters, just tell us what scope to inject to
trustedSetter
Boolean
No
false
Do not check if the setter exists, just call it, great for usage with onMissingMethod() and virtual properties
include
string
No
---
A list of columns to ONLY include in the population
exclude
string
No
---
A list of columns to exclude from the population
nullEmptyInclude
string
No
A list of keys to NULL when empty, specifically for ORM population. You can also specify "*" for all fields
nullEmptyExclude
string
No
A list of keys to NOT NULL when empty, specifically for ORM population. You can also specify "*" for all fields
composeRelationships
boolean
No
true
When true, will automatically attempt to compose relationships from memento
Key
Type
Required
Default
Description
target
any
Yes
---
The entity to populate
JSONString
string
Yes
---
The JSON packet to use for population
scope
string
No
Use scope injection instead of setter injection, no need of setters, just tell us what scope to inject to
trustedSetter
Boolean
No
false
Do not check if the setter exists, just call it, great for usage with onMissingMethod() and virtual properties
include
string
No
A list of keys to ONLY include in the population
exclude
string
No
A list of keys to exclude from the population
nullEmptyInclude
string
No
A list of keys to NULL when empty, specifically for ORM population. You can also specify "*" for all fields
nullEmptyExclude
string
No
A list of keys to NOT NULL when empty, specifically for ORM population. You can also specify "*" for all fields
composeRelationships
boolean
No
true
When true, will automatically attempt to compose relationships from memento
Key | Type | Required | Default | Description |
target | any | Yes | --- | The entity to populate |
memento | struct | Yes | --- | The structure of name-value pairs to try to populate the entity with |
scope | string | No | Use scope injection instead of setter injection, no need of setters, just tell us what scope to inject to |
trustedSetter | Boolean | No | false | Do not check if the setter exists, just call it, great for usage with onMissingMethod() and virtual properties |
include | string | No | A list of keys to ONLY include in the population |
exclude | string | No | A list of keys to exclude from the population |
nullEmptyInclude | string | No | A list of keys to NULL when empty, specifically for ORM population. You can also specify "*" for all fields |
nullEmptyExclude | string | No | A list of keys to NOT NULL when empty, specifically for ORM population. You can also specify "*" for all fields |
composeRelationships | boolean | No | true | When true, will automatically attempt to compose relationships from memento |
These methods allow you to create entities and populate them from external data like structures, json, xml, queries and much more.
Key
Type
Required
Default
Description
target
any
Yes
---
The entity to populate
xml
any
Yes
---
The xml string or xml document object to populate with
root
string
false
The xml root node to start the population with, by default it uses the XMLRoot.
scope
string
No
Use scope injection instead of setter injection, no need of setters, just tell us what scope to inject to
trustedSetter
Boolean
No
false
Do not check if the setter exists, just call it, great for usage with onMissingMethod() and virtual properties
include
string
No
A list of keys to ONLY include in the population
exclude
string
No
A list of keys to exclude from the population
nullEmptyInclude
string
No
A list of keys to NULL when empty, specifically for ORM population. You can also specify "*" for all fields
nullEmptyExclude
string
No
A list of keys to NOT NULL when empty, specifically for ORM population. You can also specify "*" for all fields
composeRelationships
boolean
No
true
When true, will automatically attempt to compose relationships from memento