You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Based on this readme listing I'm adding feedback based on existent implementations and expected lib user competencies (as we target many almost non-tech users - publisher, data wranglers etc).
// validate and cast a row according to schema$schema = newSchema('{"fields": ["name": "id", "type": "integer"]}');
$row = $schema->castRow(["id" => "1"]);
// raise exception if row fails validation// returns row with all native values// EditableSchema extends the Schema object with editing capabilities$schema = newEditableSchema();
// set fields$schema->fields([
"id" => FieldsFactory::field((object)["name" => "id", "type" => "integer"])
]);
// remove field$schema->removeField("age");
// edit primaryKey$schema->primaryKey(["id"]);
// after every change - schema is validated and will raise Exception in case of validation errors// finally, you can save the schema to a json file$schema->save("my-schema.json");
Schema vs EditableSchema?
Consider as a {DATA WRANGLER} I create $schema = new Schema('{"fields": ["name": "id", "type": "integer"]}'); in REPL then just decide to edit it. So having a deal with two type of schemas could be not very user-friendly. In other languages editable objects don't have this separation.
Accept PHP array?
It's actual for all Table/Schema/Field APIs
For now schema descriptor should be either object, json-string or url-path:
Schema objects can be constructed using any of the following:
php object
string containing json
string containg value supported by file_get_contents
Not sure do I understand PHP correctly here or not but why we can't write (using Field example):
Overview
Based on this readme listing I'm adding feedback based on existent implementations and expected lib user competencies (as we target many almost non-tech users - publisher, data wranglers etc).
Schema vs EditableSchema?
Consider as a {DATA WRANGLER} I create
$schema = new Schema('{"fields": ["name": "id", "type": "integer"]}');
in REPL then just decide to edit it. So having a deal with two type of schemas could be not very user-friendly. In other languages editable objects don't have this separation.Accept PHP array?
For now schema descriptor should be either object, json-string or url-path:
Not sure do I understand PHP correctly here or not but why we can't write (using
Field
example):instead of casting to object first:
I suppose it could be handled inside class (cast to object) but reduce usage errors.
The text was updated successfully, but these errors were encountered: