Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Sokil
@sokil
check this out!
Sergey
@serebro
great
Huy Doan
@rgv151
do you have plan to implement many-to-many relation?
Sokil
@sokil
many-to-many relation for mongodb normally implemented like embedded document.
just add list of id of some entity to field of another entity
many-to-many relation in relational databases use intermediate table, so just move this table to corresponding document, and that's all
Sokil
@sokil
hm, but i have idea of helper for this case) in some of next releases this feature will be implemented
Sokil
@sokil
You can subscribe to this issue to get notification when this feature will be implemented - sokil/php-mongo#21
Huy Doan
@rgv151
I store array of id too but I have problem w/ getter/setter I can't manipulation them directly from document
Sokil
@sokil
why?
$document->push('someRelField', $relatedDocument->getId())
$document->pushEach('someRelField', [$relatedDocument1->getId(), $relatedDocument2->getId()])
This message was deleted
Huy Doan
@rgv151

I have to referenced refField to a variable, manipulate them and set it back to the document.

From the code above, how to add/remove relatedDocument to the list?

Huy Doan
@rgv151

I'm trying to clear roles, and re-push them but I got Exception

$user->set('roles', []);
$user->pushFromArray('roles', $roles);
Uncaught exception 'MongoCursorException' with message 'localhost:27017: Cannot update 'roles' and 'roles' at the same time'

same error with $user->unsetFields('roles');

Huy Doan
@rgv151
nvm, just set them directly..
$user->set('roles', $roles);
Sokil
@sokil
it's just because you try to $set and $pushEach same field at the same time. Use set, if you want to rewrite field, or pushEach if you want tu push some values to existed field.
Jakob Murko
@sraka1
Hi @sokil
Here?
Anyways, I added a new issue. Would love to help out to get this sorted out as soon as possible.
Hope you'll have some time tomorrow to take a look at it. Cheers!
Jakob Murko
@sraka1
@sokil here?
Sokil
@sokil
Look at issue
Jakob Murko
@sraka1
Hey
One question
I'm not really sure I properly understand the caching component
You're binding it to a collection
But then you write arbitrary key/value pairs?
How does it differ from a standard cache such as memcached/redis?
Thanks
Sokil
@sokil
There is no difference. Its just cache based on mongodb. And it has some methods to invalidate cache by tags in the box.
Sokil
@sokil
And collection used as storage for values. If value is array, it may be of any structure
Daniel Coulbourne
@DanielCoulbourne
@sokil you here?
Sokil
@sokil
you can leave questions here evan i'm offline
Dan Rec
@DanRec46
i've used $collection->getDistinct('fieldname'); ..... how to use distinct with where ?
Sokil
@sokil
Before 1.12.6 allowed only Expression object, since this version - arrays and callables also. Some examples at https://github.com/sokil/php-mongo/blob/master/README.md#distinct-values
mayurmakwana
@mayurmakwana
Hello
i followed this step but