Determining gridfs collection type improvement. #779

3d0c opened this Issue Jan 9, 2013 · 1 comment


None yet

3 participants


There is a problem with a current implementation of this subject. Right now we've got this one

$defaults = compact('host') + array(
     'gridPrefix' => 'fs'
if ($source == "{$_config['gridPrefix']}.files" && isset($data['create']['file'])) {

It means that we can use only one prefix, configured into connection and the same source.

There are several solutions:

Configuring prefixes as an array, (actually not prefixes, but sources),

for example:

'gridFsCollections' => array('upload.files','source.files','storage.files','users.files'),
if(in_array($source, $_config['gridFsCollections'])){
    // do some gridfs stuff

I think this is a most lithium way.

Remove gridPrefix and check for '.files' suffix, e.g.
if(substr($str, -strlen('.files')) == '.files') {
    // do some gridfs stuff

I prefer this way, because it much seamless for user. There is no reason to naming non gridfs collections with '.files' suffix.

May be something else?

What are you think about it?


Sorry for the delay. You mean to check the grid according the .files suffix in the model's source like this ?

class MyModel extends \lithium\data\Model {
    protected $_meta = array(
        'source' => 'custom.files'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment