Comments (9)
and \Yiisoft\Data\Reader\OffsetableDataInterface
: mongodb support inserting at position (see $position
). I can imagine that there is an API endpoint that can write to a position similarly.
from data.
While such SQL makes sense, I see no use for filtering in case of writer. We have data we want to write already, it's easier and more efficient to filter data with simple foreach than by passing unfiltered data array to writer along with saving criteria.
from data.
Example SQL update:
This looks like MySQL-specific. AFAIK limit and order are not directly supported in update queries by most of DBMS.
from data.
@rob006 This is a generic Writer layer, if you have the opportunity somewhere, it is advisable to plan into the layer.
from data.
I still don't see any practical application for using filters with a data writer. We have our data, we can prepare it right away before sending it to writer. That has both simplicity and performance benefits.
from data.
I can't really see what the Writer interface is all about. I assumed that ActiveRecord would use this too, hiding the write layer, e.g. so that I can swap one NoSQL under it for another NoSQL without changing ActiveRecord class.
$ar->field2 = '22';
$ar->save();
// $ar->save() --> $db->writer() -> writer->write();
$db->writer->withFilters(new Equals('id', $ar->id))->write($ar->changedAttributes());
I implemented more database server under yii2, and I find this solution easier to implement and more flexible.
from data.
I can't really see what the Writer interface is all about.
Having array of data items, persist all of them:
$data = [
[
'id' => 1,
'name' => 'Somogyi',
],
[
'id' => 2,
'name' => 'Alex',
],
];
$writer = new ActiveRecordDataWriter(User::class);
$writer->write($data);
$db->writer->withFilters(new Equals('id', $ar->id))->write($ar->changedAttributes());
Why do you need withFilters here? Also, changed attributes isn't writer concern. That's internal thing of a possible AR specific implementation.
from data.
It's ok, if run INSERT, but if require UPDATE?
$writer = new ActiveRecordDataWriter(User::class);
$writer->write($data);
I don't really see why Writer
filters are provided wit AR, whereas Reader
filters are not.
$db->writer->withFilters(new LessThan('id', 88))->write($attributes);
// === yii2 AR->updateAll($attributes, ['<', 'id', 88]);
If I use simple types, I just need to replace the Writer
and write to almost any target destination (RDBMS, NoSQL, Redis), eg with custom BasicActiveRecord. If ActiveRecord does this (why?), Then I need to create a N versions of class because they must extends from different classes.
Nonetheless, I already understand that this is not a real Writer
layer, but some very simplified implementation, and I probably need to see the rest of the system to understand why.
from data.
Yes, that wasn't meant to replace AR or provide full-featured abstraction over any storage. Let's assume it won't be needed to reuse filters for writer.
from data.
Related Issues (20)
- Check Like filter with iterable data provider HOT 1
- Avoid psalm suppresses
- Implement callable data processor HOT 1
- Fix psalm errors HOT 1
- Add `iterable` support in `DataProcessorInterface` HOT 1
- Paginator refactoring concept HOT 2
- Remove `PaginatorInterface` HOT 2
- Increase test coverage to 100%
- Rename filter processor to handler
- Improve namespacing HOT 1
- Move `FilterDataValidationHelper::assertFilterHandlerIsIterable()` method to `Iterable` namespace HOT 2
- Allow pass criteria array to `Group` (reader) filter constructor HOT 1
- Throws exception when pass to `IterableDataReader` non-`IterableFilterHandlerInterface` filter handlers HOT 2
- Make accessing item methods explicit or not? HOT 2
- Add suffix `Handler` for all filter handlers HOT 1
- Finalize `IterableDataReader` HOT 4
- Create DeletableInterface HOT 1
- Sort and function getCriteria HOT 11
- Add DateTimeInterface support to Between filter or create BetweenDate filter
- sort by datetime fields HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from data.