我正在尝试使用连接器将strongloop连接到MySql数据库,我能够获取除“用户”之外的所有表的记录,其中包含以下详细信息[
{
"userEmailId": "string",
"userPassword": "string",
"firstname": "string",
"lastname": "string",
"roleId": 0,
"mobileNumber": "string",
"userStatus": 0,
"createdBy": 0,
"createdDate": "2016-02-12",
"modifiedBy": 0,
"modifiedDate": "2016-02-12",
"isdeleted": 0,
"oldpassword": "string",
"profilePicturename": "string",
"address": "string",
"userId": 0,
"realm": "string",
"username": "string",
"credentials": {},
"challenges": {},
"email": "string",
"emailVerified": true,
"verificationToken": "string",
"status": "string",
"created": "2016-02-12",
"lastUpdated": "2016-02-12"
}
]
作为模型场景。
但是当我在get按钮上创建@ url“http://localhost:3000/explorer/#!/User/User_find”
我正在{
"error": {
"name": "Error",
"status": 401,
"message": "Authorization Required",
"statusCode": 401,
"code": "AUTHORIZATION_REQUIRED",
"stack": "Error: Authorization Required\n at C:\\Users\\anupd\\Desktop\\loopback-getting-started\\node_modules\\loopback\\lib\\application.js:376:21\n at C:\\Users\\anupd\\Desktop\\loopback-getting-started\\node_modules\\loopback\\lib\\model.js:313:7\n at C:\\Users\\anupd\\Desktop\\loopback-getting-started\\node_modules\\loopback\\common\\models\\acl.js:465:23\n at C:\\Users\\anupd\\Desktop\\loopback-getting-started\\node_modules\\async\\lib\\async.js:251:17\n at done (C:\\Users\\anupd\\Desktop\\loopback-getting-started\\node_modules\\async\\lib\\async.js:132:19)\n at C:\\Users\\anupd\\Desktop\\loopback-getting-started\\node_modules\\async\\lib\\async.js:32:16\n at C:\\Users\\anupd\\Desktop\\loopback-getting-started\\node_modules\\async\\lib\\async.js:248:21\n at C:\\Users\\anupd\\Desktop\\loopback-getting-started\\node_modules\\async\\lib\\async.js:572:34\n at C:\\Users\\anupd\\Desktop\\loopback-getting-started\\node_modules\\loopback\\common\\models\\acl.js:447:17\n at C:\\Users\\anupd\\Desktop\\loopback-getting-started\\node_modules\\loopback\\common\\models\\role.js:268:21"
}
}
anybudy可以帮助我解决这个问题,或者可以告诉我如何扩展inbuild用户模块以匹配我的问题
提前致谢
答案 0 :(得分:0)
我们无法阅读内置的USER模型。默认情况下,strongloop拒绝访问。
您只需创建自定义模型并继承Inbuilt USER模型,然后您将获得内置USER模型的所有功能。
在你的model.json中做。 “base”:“用户”,
EX:型号名称,如customer.js
{
"name": "customer",
"base": "User",
"idInjection": false,
"options": {
"validateUpsert": true
},