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

User.findOrCreate is not a function #69

Open
Arunps94 opened this issue Jul 30, 2020 · 6 comments
Open

User.findOrCreate is not a function #69

Arunps94 opened this issue Jul 30, 2020 · 6 comments

Comments

@Arunps94
Copy link

** READ THIS FIRST! **

Are you looking for help?

Reminder: The issue tracker is not a support forum.

Issues should only be filed in this project once they are able to be reproduced
and confirmed as a flaw in the software or incorrect information in associated
documention.

If you are encountering problems integrating this module into your application,
please post a question on the discussion forum
rather than filing an issue.

Is this a security issue?

Do not open issues that might have security implications. Potential security
vulnerabilities should be reported privately to jaredhanson@gmail.com. Once any
vulerabilities have been repaired, the details will be disclosed publicly in a
responsible manner. This also allows time for coordinating with affected parties
in order to mitigate negative consequences.

If neither of the above two scenarios apply to your situation, you should open
an issue. Delete this paragraph and the text above, and fill in the information
requested below.

Expected behavior

Actual behavior

Steps to reproduce

// Format code using Markdown code blocks

Environment

  • Operating System:
  • Node version:
  • passport version:
  • passport-google-oauth2 version:
@colmer
Copy link

colmer commented Aug 9, 2020

HI @Arunps94, User.findOrCreate must be your own method.

@humaidk2
Copy link

Hi,
Just to add to that, User.findOrCreate is the method used to insert the user's data into your own database, once the data has been retrieved from google's api.
You can use any other database insertion method as long as you call the callback cb(null,user) on successful insertion and cb(error,user) on error or if you aren't using a database, just call cb(null,profile).
Basically the second argument for the callback method will be your session data, accessible through req.session.passport.user

@sharmadeep698
Copy link

hey ,
just to make that code working, try adding a npm package which will make findorcreate a proper function to work with. for more

@DaminiPandey
Copy link

DaminiPandey commented Jul 8, 2021

By simply installing mongoose-findorcreate (npm package) ,requiring it in your app.js and adding it as a plugin in your schema would make this function work as it is!

@pablomusumeci
Copy link

@Arunps94 Can you please close this issue? It doesn't seem to be related to this library at all. Thanks!

@binayak597
Copy link

binayak597 commented Dec 24, 2022

See, This is not a method of mongoose it is actually a npm package named "mongoose-findOrCreate". You have to install and require it on your project inorder to use this. Actually under this package there are two mongoose methods have implemented by the developers which are findOne() and save() and they have bounded these two methods on this package.

https://www.npmjs.com/package/mongoose-findorcreate

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

No branches or pull requests

7 participants