我正在尝试为sailsjs v1模型创建蓝图查询.
该模型是一个BlogPost,有2个"选项".一个是目标,另一个是状态.
如果目标是Site并且状态为Published,则应返回查询,否则为nope.我正在使用Sails提供的默认REST路由(蓝图),如果我试图找到所有这些路由,一切正常.但是,如果我试图通过ID找到一个...我甚至无法找回状态为"未发布"的那些.
这是我的代码blueprint.js parseBlueprintOptions- >
parseBlueprintOptions: function (req) {
var queryOptions = req._sails.hooks.blueprints.parseBlueprintOptions(req);
if (queryOptions.using === 'blogpost') {
if (req.options.blueprintAction === 'create') {
queryOptions.newRecord.user_id = req.session.user.id;
return queryOptions;
} else if (req.options.blueprintAction === 'update') {
queryOptions.criteria.where.user_id = req.session.user.id;
queryOptions.valuesToSet.user_id = req.session.user.id;
return queryOptions;
} else {
if (req.session.administrator) {
return queryOptions;
} else {
queryOptions.criteria.where.blogpost_target = 'Site';
queryOptions.criteria.where.blogpost_status = 'Published';
console.log(queryOptions);
return queryOptions;
}
}
}
}
};
Run Code Online (Sandbox Code Playgroud)
有关为什么不触发查询的提示findOne?正如我所说,无论状态/目标如何,它都会返回.
我正在使用JWT令牌身份验证的API。我已经在其背后创建了一些逻辑,以使用验证码等更改用户密码。
一切正常,密码更改。但这很重要:即使用户密码已更改,并且在身份验证时我得到了新的JWT令牌,旧令牌仍然有效。
关于密码更改后如何刷新/使令牌失效的任何提示?
编辑:因为我听说您实际上不能使JWT令牌无效,所以我对如何做到这一点有所了解。我的想法是创建一个具有“ accessCode”之类的新用户列,并将该访问代码存储在令牌中。每当我更改密码时,我也会更改accessCode(类似于6位数的随机数),并且在进行API调用时会执行对该accessCode的检查(如果令牌中使用的访问代码与db中的访问代码不匹配->返回未授权)。
你们认为这是个好方法还是还有其他方法吗?
我正在使用 IActionResult(任务)上传文件,并在我的控制器中引用该文件。我想取回的是文件名。
控制器 ->
var imageLocation = await _imageHandler.UploadImage(image);
Run Code Online (Sandbox Code Playgroud)
ImageHandler ->
public async Task<IActionResult> UploadImage(IFormFile file)
{
var result = await _imageWriter.UploadImage(file);
return new ObjectResult(result);
}
Run Code Online (Sandbox Code Playgroud)
我的值存储在 imageLocation 中,但我不知道如何访问它(我需要“值”字符串以便我可以将它添加到数据库中)。
我尝试过搜索所有内容,但每个人都在使用列表。我这里只需要一个字符串。希望大家能帮帮我。谢谢!
到目前为止,我已经尝试了所有能找到的方法,但仍然收到错误“导出未定义”。
我正在使用 ReactJS.NET(适用于 NetCore2),这是强制性的,否则我的整个应用程序将无法在 NetCore2 下加载。
这是我的.babelrc
{
"presets": [
"@babel/preset-react",
"@babel/preset-env",
"@babel/preset-typescript"
],
"plugins": [
"add-module-exports",
"@babel/plugin-proposal-class-properties",
[
"@babel/plugin-transform-runtime",
{
"corejs": 2,
"helpers": true,
"regenerator": true,
"useESModules": true
}
]
]
}
Run Code Online (Sandbox Code Playgroud)
旧版 babel 和“add-module-exports”的一切都运行良好。babel 7 有替代品吗?
我在ReactJS中开发一个应用程序,我在使用以下应用程序:MaterialUI(用于react)和React Flexbox。
我遇到的问题是尝试将卡按钮定位在底部(该问题似乎在不同的框架中散布了互联网)。我正在从这里使用卡-> https://material-ui.com/demos/cards/
从align-items到align-self和不同的显示类型,我已经尝试了几乎所有我能想到的东西。由于我通常与Bootstrap合作,因此我可能会在这里遗漏某些东西,因此希望CSS Master可以为我提供帮助。我将在下面附上图片供参考。
另外作为参考,这是我的代码在react中的外观(ApiPosts是我的卡片组件)->
<Grid container>
<Grid item xs={12}>
<Paper className={classes.paper}>
<Row className="rowSpacer">
<Col xs>
<Typography variant="title" align="center" color="textPrimary" gutterBottom>
Posts are below
</Typography>
</Col>
</Row>
<Divider />
<ApiPosts />
</Paper>
</Grid>
</Grid>
Run Code Online (Sandbox Code Playgroud)
最后,我的卡片被包裹起来<Row around="xs">(连续4个帖子),每个卡片都放在一个格子中<Col xs >
提前致谢!
编辑:感谢Ivan的回答,解决了这里的代码,以防万一需要它(在Material-UI卡上工作)。
.portCardCl {
display: flex;
flex-direction: column;
height:100%;
}
.portBodyCl {
display: flex;
flex: 1 0 auto;
align-items: flex-end;
justify-content: center;
flex-direction: column;
}
.portButCl{
display: flex;
justify-content: flex-start;
}
Run Code Online (Sandbox Code Playgroud)
portCardCl首先<Card>,portBodyCl继续 …
我有一个安装了ReactJS的NetCore2应用程序。
我的React应用程序做了这样的事情->
我正在使用Office Fabric UI React-People Picker(以防万一)。
我的问题是我不知道如何在代码中使用async / await。
如果我把这样的东西
async asynconFilterChanged = (filterText, currentPersonas, limitResults) => {
VS Code引发错误,告诉我异步仅适用于.ts文件。另外,如果我在任何其他函数中使用await,我将收到诸如的错误await is a reserved word。
据我所知异步/等待不只是TS ...(或者我错了吗?)。
我正在使用带有ENV预设的较旧的Babel。
让我知道是否需要提供更多代码,但是TLDR我想要的是仅在axios完成将项目推入PeopleList状态(对象数组)后才启动过滤器功能。
谢谢!
我正在尝试创建一个模型类,其中包含一些方法来简化从 Firebase 检索信息的过程。
我有一个“未注册”页面,用户单击“使用谷歌登录”按钮。如果我的用户已经注册,它会检查数据库以查看他是否完成了他的个人资料,否则它会使用一个字段将基本数据写入数据库,profileCompleted: false并将用户重定向到个人资料页面,以便他可以完成他的个人资料。
我试图在这里使用一个模型,但我遇到了各种各样的错误(刚刚开始学习 flutter/dart)。
我将分享一些代码,如果还不够,请告诉我!
未注册页面。
if (user != null) {
await prefs.setString('id', user.uid);
// Check is already sign up
final QuerySnapshot result = await Firestore.instance
.collection('users')
.where('id', isEqualTo: user.uid)
.getDocuments();
final List<DocumentSnapshot> documents = result.documents;
if (documents.length == 0) {
debugPrint("User not in DB ?");
//debugPrint(userInfo.toString());
// Update data to server if new user
Firestore.instance.collection('users').document(user.uid).setData({
'id': user.uid,
'nickname': user.displayName,
'photoUrl': user.photoUrl,
'email': user.email,
'createdAt': DateTime.now(),
'provider': user.providerId,
'profileCompleted': false,
'bloodType': 'A',
'rhType': 'Negativ',
'donatedBefore': …Run Code Online (Sandbox Code Playgroud) reactjs ×3
c# ×2
javascript ×2
async-await ×1
asynchronous ×1
babel-loader ×1
babeljs ×1
css ×1
dart ×1
flutter ×1
jwt ×1
material-ui ×1
node.js ×1
reactjs.net ×1
sails.js ×1
webpack ×1