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
Spent a lot of time battling with this (excellent, beloved package) today to make it work with MongoDB. For anyone who is thinking of doing the same, here's the info to save you the time. Laravel's documentation now includes info on MongoDB and Sail also includes the PHP extension by default.
First up: Mongo creates things on the fly. Writing a database manager requires getting hold of the underlying database client using getMongoClient(). A database MUST have at least one collection in it.
Next up, the default models (Domain, Impersonate, Tenant, etc) have to extend the MongoDB driver, and specify collection and keys. The key type is CRUCIAL here to avoid errors because it defaults to "id" which does not exist.
Finally, the crucial piece: the "data" column. This isn't needed in Mongo because it's a giant JSON document. The problem here is VirtualColumn (being replaced in v4?) because as it cycles through an object attributes to store them, it chokes on Mongo's datetime fields.
Two functions need altering in the VirtualColumn class:
The problem here is VirtualColumn (being replaced in v4?)
It's not being replaced but there will be a new major version of virtualcolumn. If you think there's something we can address in that package to improve compatibility with these setups, could you open an issue in that repo? Will take a look at it 👍
Sure thing. It may not need to be touched at all when using Mongo really, as it's idempotent and the whole document is a virtualcolumn (so to speak). So in pseudo, if using sql rdbms, use VC; if using nosql, just add fields in any way you like. Ish. Kinda.
Btw this package needs to be part of the Laravel core. I've found myself using it in most projects so i don't have to go back later to add it.
Spent a lot of time battling with this (excellent, beloved package) today to make it work with MongoDB. For anyone who is thinking of doing the same, here's the info to save you the time. Laravel's documentation now includes info on MongoDB and Sail also includes the PHP extension by default.
First up: Mongo creates things on the fly. Writing a database manager requires getting hold of the underlying database client using
getMongoClient()
. A database MUST have at least one collection in it.In
config/tenancy.php
, it needs to be added as a driver:Next up, the default models (Domain, Impersonate, Tenant, etc) have to extend the MongoDB driver, and specify collection and keys. The key type is CRUCIAL here to avoid errors because it defaults to "id" which does not exist.
In
config/tenancy.php
, they need to be replaced with your own:Finally, the crucial piece: the "data" column. This isn't needed in Mongo because it's a giant JSON document. The problem here is
VirtualColumn
(being replaced in v4?) because as it cycles through an object attributes to store them, it chokes on Mongo's datetime fields.Two functions need altering in the
VirtualColumn
class:For query checking with Debugbar, do this in
AppServiceProvider::boot()
:The text was updated successfully, but these errors were encountered: