如果用户数据 = "NULL" 则进行流星测试
Meteor test if Users datas = "NULL"
我想测试我的 currentUser 是否在他的用户集合中
-> profileType:"NULL"(默认值)。
如果 profileType != "NULL" 我会将用户重定向到另一个模板。
我不知道哪里最合适?
- 在带有 onBeforeAction 的路由器中
- 在客户帮手上
- 在服务器端调用一个方法
提前致谢
取决于您想要的行为。
onBeforeAction
如果您将它放在这里,您的应用将在检查时等待并显示您的加载模板。
如果将其放入客户端助手中,当数据发生变化时,您将有一个明显的 UI 变化。
如果您使用服务器端方法,那么您还应该使用 onBeforeAction
来等待您的调用。
这是一个非常广泛的问题#Idls,但这里有一些地方可以开始。
I want to test if my currentUser have in his users collection
-> profileType: "NULL" (default value).
查看 Collections2 和 SimpleSchema Meteor 包。 Understand and implement this.
and if profileType != "NULL" i will redirect the user to an other template.
I don't where will be the best place to do it ?
This question will help you with that.
到目前为止,最简单快捷的方法就是在 Blaze 中进行:
{{#if profileType}}
{{> nonNullProfileTypeTemplate}}
{{else}}
{{> nullProfileTypeTemplate}}
{{/if}}
这利用了 null 是 false-y 的事实。
您也可以在路由器中执行此操作,但在 IMO 的情况下,这种方法几乎没有优势。
我想测试我的 currentUser 是否在他的用户集合中
-> profileType:"NULL"(默认值)。
如果 profileType != "NULL" 我会将用户重定向到另一个模板。
我不知道哪里最合适?
- 在带有 onBeforeAction 的路由器中
- 在客户帮手上
- 在服务器端调用一个方法
提前致谢
取决于您想要的行为。
onBeforeAction
如果您将它放在这里,您的应用将在检查时等待并显示您的加载模板。
如果将其放入客户端助手中,当数据发生变化时,您将有一个明显的 UI 变化。
如果您使用服务器端方法,那么您还应该使用 onBeforeAction
来等待您的调用。
这是一个非常广泛的问题#Idls,但这里有一些地方可以开始。
I want to test if my currentUser have in his users collection
-> profileType: "NULL" (default value).
查看 Collections2 和 SimpleSchema Meteor 包。 Understand and implement this.
and if profileType != "NULL" i will redirect the user to an other template.
I don't where will be the best place to do it ?
This question will help you with that.
到目前为止,最简单快捷的方法就是在 Blaze 中进行:
{{#if profileType}}
{{> nonNullProfileTypeTemplate}}
{{else}}
{{> nullProfileTypeTemplate}}
{{/if}}
这利用了 null 是 false-y 的事实。
您也可以在路由器中执行此操作,但在 IMO 的情况下,这种方法几乎没有优势。