Is there any way to persist to a file model created by API db.buildModelFromInstance()

10 views
Skip to first unread message

Haresh Gujarathi

unread,
Jun 13, 2018, 9:39:55 AM6/13/18
to LoopbackJS
Hi

I have database in MongoDB with several collections already defined with some data in it. I want to create model files for each of the collection. Is there a way to create such?

I see an API

var User = db.buildModelFromInstance('User', user, {idInjection: true});

Can this be used to persist the model created in a file and then I can use it to enhance further with relation definitions etc?

Regards

Aman Alam

unread,
Jun 13, 2018, 12:30:37 PM6/13/18
to loopb...@googlegroups.com
You can use model discovery.

Loopback supports model discovery (creating models from rdbms schema) from many db providers but unfortunately mongodb is not one of them.
For mongodb, they sugggest an approach like the one described in the link above




--
You received this message because you are subscribed to the Google Groups "LoopbackJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to loopbackjs+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/loopbackjs/9646e071-7131-41ec-bf37-3202536a8615%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages