dilab / cake-mongo Goto Github PK
View Code? Open in Web Editor NEWMongoDB for CakePHP 3.0 (entity and table)
MongoDB for CakePHP 3.0 (entity and table)
Hi,
I have a question about database configuration. In your document, you write example only className and driver to pit in data sources so my question is where do I put database config and with what key?
Thanks in advance.
Hi,
I can not use the entity validation system. For example, $validator->notEmpty ('myfield', 'message');
Can you give an example?
If you try to edit or to add an object in your database, you could have this error:
Error: Undefined class constant 'BUILD_VALIDATOR_EVENT'
File C:\wamp64\www\bob_dilab\vendor\cakephp\cakephp\src\Validation\ValidatorAwareTrait.php
Line: 176
I added the class constant in file vendor\dilab\cake-mongo\src\Collection.php:
const BUILD_VALIDATOR_EVENT = 'Model.buildValidator';
Its the same value than in the file vendor\cakephp\cakephp\src\ORM\Table.php
I don't know if it is the right way to fix it but it made the trick for me.
Unknown repository type "Mongo". Make sure you register a type before trying to use it.
When i try to add an article.
Coming from this function in the controller:
public function beforeFilter(Event $event)
{
parent::beforeFilter($event);
// Load the Collection using the 'Mongo' provider.
$this->loadModel('Articles', 'Mongo');
}
hydrate(false) method does not implemented in this plugin? to get the result set in Array instead getting dirty fields
Hey, i'm using a Mongo and a MySQL database at the same time.
My virtual fields are not working for my MySQL tables, I think that the mongo configuration of the entities is
overwriting the default config.
Any solution ?
This simple code doesn't work
$this->loadModel('Pages', 'Mongo');
$pages = $this->Pages->find('all')->where(['parent'=>'root'])->limit(10);
$page = $this->Pages->newEntity();
I see that Dilab\CakeMongo\Query::compileQuery is returning:
[
'limit' => (int) 10,
'filter' => [
'parent' => 'root'
]
]
But MongoDB\Collection expects filter without filter key and limit is a searchOption:
/**
* Finds documents matching the query.
*
* @see Find::__construct() for supported options
* @see http://docs.mongodb.org/manual/core/read-operations-introduction/
* @param array|object $filter Query by which to filter documents
* @param array $options Additional options
* @return Cursor
* @throws UnsupportedException if options are not supported by the selected server
* @throws InvalidArgumentException for parameter/option parsing errors
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/
public function find($filter = [], array $options = [])
So rewriting compileQuery as the following code make a simple find works:
public function compileQuery()
{
if ($this->_parts['fields']) {
$this->_searchOptions['projection'] =
array_combine($this->_parts['fields'], array_fill(0, count($this->_parts['fields']), 1));
}
if ($this->_parts['limit']) {
$this->_searchOptions['limit'] = $this->_parts['limit'];
}
if ($this->_parts['offset']) {
$this->_searchOptions['skip'] = $this->_parts['offset'];
}
if ($this->_parts['order']) {
$this->_searchOptions['sort'] = collection($this->_parts['order'])->map(function ($item) {
$key = key($item);
$order = $item[$key];
return [
'key' => $key,
'order' => ($order['order'] == 'desc' ? -1 : 1)
];
})->reduce(function ($carry, $item) {
$carry[$item['key']] = $item['order'];
return $carry;
}, []);
}
if ($this->_parts['filter']) {
$this->_mongoQuery = array_reduce($this->_parts['filter'], function ($carry, AbstractFilter $filter) {
$filterArray = $filter->toArray();
$carry = array_merge($carry, $filterArray);
return $carry;
}, []);
}
return $this->_mongoQuery;
}
I have created UserEntity and UsersTable file but it doesn't work.So is this plugin support this or not.
How to manage datatype for collection coloumn?
Is this project still active ?
Can you please port this to work with CakePHP 3.3.
Or can you help me doing it, I'm new to Cake.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.