[英]How to import or create loopback Access control related tables from memory datasource to mysql datasource in loopbackJS?
I am trying to create or import LoopbackJS AccessToken, ACL, RoleMapping, Role tables from default memory based datasource db
to my MySQL datasource. 我试图从基于默认内存的数据源
db
创建或导入LoopbackJS AccessToken,ACL,RoleMapping,Role表到我的MySQL数据源。 I defined a model Customer
which extends built-in User
model. 我定义了一个模型
Customer
,它扩展了内置的User
模型。 My files are as below 我的档案如下
server/datasources.js server / datasources.js
{
"db": {
"name": "db",
"connector": "memory"
},
"accountDs": {
"host": "nmrony.local",
"port": 3306,
"database": "loopback_experiments",
"username": "admin",
"password": "****",
"name": "accountDs",
"connector": "mysql"
}
}
server/model-config.js 服务器/模型-config.js
{
"_meta": {
"sources": [
"loopback/common/models",
"loopback/server/models",
"../common/models",
"./models"
]
},
"AccessToken": {
"dataSource": "accountDs",
"public": false
},
"ACL": {
"dataSource": "accountDs",
"public": false
},
"RoleMapping": {
"dataSource": "accountDs",
"public": false
},
"Role": {
"dataSource": "accountDs",
"public": false
},
"Account": {
"dataSource": "accountDs",
"public": true
},
"Customer": {
"dataSource": "accountDs",
"public": true
}
}
and 和
common/models/customer.json common / models / customer.json
{
"name": "Customer",
"base": "User",
"idInjection": true,
"properties": {
"accountNumber": {
"type": "number"
}
},
"validations": [],
"relations": {},
"acls": [],
"methods": []
}
Which gives me Customer
model fields are 这给了我
Customer
模型字段是
{
"accountNumber": 0,
"realm": "",
"username": "",
"credentials": "object",
"challenges": "object",
"email": "",
"emailVerified": false,
"verificationToken": "",
"status": "",
"created": "",
"lastUpdated": "",
"id": 0
}
How can I import or create customer and All ACL, Role related tables and accesstoken table in my mysql database? 如何在我的mysql数据库中导入或创建客户以及所有ACL,与角色相关的表和accesstoken表? In fact I don't want to use built-in memory datasource at all.
实际上,我根本不想使用内置的内存数据源。
you'd better to change following. 您最好更改关注者。
common/models/customer.json common / models / customer.json
{
"name": "Customer",
"base": "User",
"idInjection": true,
"options" : {
"mysql" : {
"schema": "myapp",
"table": "user"
}
}
"properties": {
"accountNumber": {
"type": "number"
}
},
"validations": [],
"relations": {},
"acls": [],
"methods": []
}
and put acl.json, role.json, rolemapping.json like above format with "options". 并像上面的格式一样将acl.json,role.json,rolemapping.json放入“选项”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.