Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please help #1103

Closed
phuocduy1988 opened this issue Feb 3, 2017 · 3 comments
Closed

Please help #1103

phuocduy1988 opened this issue Feb 3, 2017 · 3 comments
Labels

Comments

@phuocduy1988
Copy link

phuocduy1988 commented Feb 3, 2017

I am using your project laravel-mongodb. It is very helpful for me.
However, I have some problem when using laravel-mongodb.

  1. How I create a collection with custom field when insert -> like:
    {
    '_id' : AUTO_INCREMENT
    'username' : unique (phuocduy1988)
    'view_count' : interger 64 bit ()
    'average' : double
    }

  2. How to make index for username

  3. Please give me more example how to using:
    $client = DB::getMongoClient();
    $db = DB::getMongoDB();

  4. I cannot using DB in laravel Controller
    $client = DB::collection('spot')->where('name', 'John')->get();
    I got an error:
    Call to undefined method Illuminate\Database\MySqlConnection::collection();

Please help me!

@nguaman
Copy link

nguaman commented Mar 13, 2017

I have the same issue.

@nguaman
Copy link

nguaman commented Mar 13, 2017

I found the Solution for this error.
You have to use this

$db = \DB::connection('mongodb')->getMongoClient();

and mongodb is the name that you use in the config/database.php

@phuocduy1988
Copy link
Author

Thank Wu4m4n,
I found other solution.
I custom other class to connect direct to mongodb via php driver mongodb/mongodb.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants