环回 - 用户模型不在我的文件夹中?
loopback - user model not in my folder?
我正在为使用用户模型的预建项目的项目使用环回。
但是,我无法获取用户。我研究了一下,发现有办法改变它;但是我在 common/models 中找不到其他型号的用户文件(user.js 和 user.json)。
我在我的 postgres 数据库中也看不到它。
这是为什么?我是否应该从 loopback 的 github 存储库粘贴文件(user.json 和 user.js)并使用脚本 "automigration" 才能看到它?
however I do not find the user files (user.js and user.json) in
common/models
用户模型是内置模型,您可以在node_modules/loopback/common/models
中找到它。
I also cannot see it on my postgres database. Why is that? Should I
paste the files (user.json and user.js) from the github repository of
loopback and use the script "automigration" to be able to see it?
如果您正在使用内置模型(您几乎可以肯定是因为 loopback 默认加载内置模型),您已经可以 运行 来自 documentation
var server = require('./server');
var ds = server.dataSources.db;
var lbTables = ['User', 'AccessToken', 'ACL', 'RoleMapping', 'Role'];
ds.automigrate(lbTables, function(er) {
if (er) throw er;
console.log('Loopback tables [' + lbTables + '] created in ', ds.adapter.name);
ds.disconnect();
});
我正在为使用用户模型的预建项目的项目使用环回。
但是,我无法获取用户。我研究了一下,发现有办法改变它;但是我在 common/models 中找不到其他型号的用户文件(user.js 和 user.json)。
我在我的 postgres 数据库中也看不到它。
这是为什么?我是否应该从 loopback 的 github 存储库粘贴文件(user.json 和 user.js)并使用脚本 "automigration" 才能看到它?
however I do not find the user files (user.js and user.json) in common/models
用户模型是内置模型,您可以在node_modules/loopback/common/models
中找到它。
I also cannot see it on my postgres database. Why is that? Should I paste the files (user.json and user.js) from the github repository of loopback and use the script "automigration" to be able to see it?
如果您正在使用内置模型(您几乎可以肯定是因为 loopback 默认加载内置模型),您已经可以 运行 来自 documentation
var server = require('./server');
var ds = server.dataSources.db;
var lbTables = ['User', 'AccessToken', 'ACL', 'RoleMapping', 'Role'];
ds.automigrate(lbTables, function(er) {
if (er) throw er;
console.log('Loopback tables [' + lbTables + '] created in ', ds.adapter.name);
ds.disconnect();
});