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

[Add Keystone to Existing Apps] How to Utilize Existing Mongoose Models #1508

Closed
Plypy opened this Issue Jul 2, 2015 · 7 comments

Comments

Projects
None yet
8 participants
@Plypy

Plypy commented Jul 2, 2015

Based on the instruction given in WIKI, I modified my app.
Added this line to import my models defined.

keystone.imports('models')

Thing is, though I can access the keystone admin panel, I can't see anything. The panel is empty, no model monitored there.

Should I do a list.register() first to see it's shown in the panel. If it is, then how I can register a well-defined Mongoose model, or must I rewrite the model in keystone's List style?

Regards.

@shaond

This comment has been minimized.

shaond commented Jul 27, 2015

I have the same question as @Plypy, we have an existing app with quite a large number of models which are shared amongst a number of ExpressJS apps, but I'd love to integrate Keystone's Admin UI goodness.

We've got Keystone's route working, but like the OP, there's nothing in the Admin UI. A rewrite of our models into Keystone's List based format wouldn't be practical.

Is there a way to use our existing Mongoose models with Keystone's Admin UI?

@hustKiwi

This comment has been minimized.

hustKiwi commented Sep 2, 2015

+1

@morenoh149

This comment has been minimized.

Member

morenoh149 commented Sep 2, 2015

@Plypy where is imports defined? it's not in keystone or mongoose.

@hustKiwi
list.register() is run from a mongoose object (I think) so try

Keystone.prototype.register.call(yourMongooseObject)

and see if it get's wired up correctly.

@cameronroe

This comment has been minimized.

cameronroe commented Sep 3, 2015

@Plypy Pretty sure the method is keystone.import

Alternatively, you can just require('./models') from your keystone.js file before the routes. https://github.com/JedWatson/keystone-demo/blob/master/keystone.js#L38

@AlexYegupov

This comment has been minimized.

AlexYegupov commented Mar 9, 2016

+1 to shaond question
Is there ability or future plans to allow using in keystone existing application mongoose models without necessity to redefine their duplicates via MyMongooseModel.add({...})?

@creynders

This comment has been minimized.

Contributor

creynders commented Mar 10, 2016

@AlexYegupov I can't quite imagine how that would work, since keystone lists add a lot of functionality. Some kind of mapping mechanism? E.g. a mongoose schema defines a field as a string but keystone'll need to know what kind of string that is. Is it a text field? Or is it a Url? Et cetera.

@mxstbr

This comment has been minimized.

Member

mxstbr commented Apr 29, 2016

We're closing all questions and support requests to keep the issue tracker unpolluted. Please ask this question on Stackoverflow or Gitter instead!

@mxstbr mxstbr closed this Apr 29, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment