Skip to content

Commit b21fdf7

Browse files
committed
update readme
1 parent 4b21a38 commit b21fdf7

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

lib/db/cortex.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2223,7 +2223,7 @@ function copyto_flat($key) {
22232223
&& $f3->devoid($key.'.'.$field)) {
22242224
$val = $this->get($field);
22252225
if ($val instanceof CortexCollection)
2226-
$f3->set($key.'.'.$field,$val->getAll('id'));
2226+
$f3->set($key.'.'.$field,$val->getAll('_id'));
22272227
elseif (is_array($val))
22282228
$f3->set($key.'.'.$field,$val);
22292229
else

readme.md

+29-2
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ Defines the used primary key of the table. Default is `id` for SQL engine, and *
934934
**Retrieve first object that satisfies criteria**
935935

936936
```php
937-
Cortex load([ array $filter = NULL [, array $options = NULL [, int $ttl = 0 ]]])
937+
bool load([ array $filter = NULL [, array $options = NULL [, int $ttl = 0 ]]])
938938
```
939939

940940
Simple sample to load a user:
@@ -950,7 +950,7 @@ if (!$user->dry()) {
950950
```
951951

952952
When called without any parameter, it loads the first record from the database.
953-
953+
The method returns `TRUE` if the load action was successful.
954954

955955
### loaded
956956
**Count records that are currently loaded**
@@ -1199,6 +1199,15 @@ $news->copyfrom('POST',function($fields) {
11991199
null copyto( string $key [, array|string $relDepth = 0 ])
12001200
```
12011201

1202+
### copyto_flat
1203+
**Copy mapper values to hive key with relations being simple arrays of keys**
1204+
1205+
```php
1206+
null copyto_flat( string $key )
1207+
```
1208+
1209+
All `has-many` relations are being returned as simple array lists of their primary keys.
1210+
12021211

12031212
### count
12041213
**Count records that match criteria**
@@ -1239,6 +1248,16 @@ string dbtype()
12391248

12401249
The type is `SQL`, `Mongo` or `Jig`.
12411250

1251+
1252+
### defaults
1253+
**Return default values from schema configuration**
1254+
1255+
```php
1256+
array defaults([ bool $set = FALSE ])
1257+
```
1258+
1259+
Returns a `$key` => `$value` array of fields that has a default value different than `NULL`.
1260+
12421261
### dry
12431262
**Return TRUE if current cursor position is not mapped to any record**
12441263

@@ -1472,6 +1491,14 @@ null reset([ bool $mapper = true ])
14721491

14731492
If `$mapper` is *false*, it only reset filter, default values and internal caches of the mapper, but leaves the hydrates record untouched.
14741493

1494+
### resetFields
1495+
**reset only specific fields and return to their default values**
1496+
1497+
```php
1498+
null resetFields( array $fields )
1499+
```
1500+
1501+
If any field doesn't have a default value, it's reset to `NULL`.
14751502

14761503
### resolveConfiguration
14771504
**kick start mapper to fetch its config**

0 commit comments

Comments
 (0)