在Node.JS Web应用程序中使用mongoDB(Using mongoDB in Node.JS web application)
我正在使用Node.JS编写一些简单的Web应用程序,并希望将mongoDB用作主数据存储。
Node-mongodb-native驱动程序需要在实际查询或存储数据之前进行链式调用(打开数据库连接,进行身份验证,获取集合)。
在初始化应用程序时,在每个请求处理程序内或全局执行此初始化的最佳位置在哪里?I'm writing some simple web app with Node.JS and want to use mongoDB as main data storage.
Node-mongodb-native driver requires to make chained calls before you actually can query or store data (open DB connection, authenticate, get collection).
Where is the best place to do this initialization - within each request handler or globally, when initializing application?
原文:https://stackoverflow.com/questions/11985658
最满意答案
使用SPList.Items不会返回所有项目? 好吧,然后尝试SPList.GetItems(SPQuery) 。
有一个以下的SPQuery:
SPQuery query = new SPQuery(); query.ViewFields = "<FieldRef Name='ID'/><FieldRef Name='Title'/>"; query.Query = String.Format("<Where><Eq><FieldRef Name='Title'/><Value Type='Text'>{0}</Value></Eq></Where>", someItemTitle) query.MeetingInstanceId = -1; //In case if you query recurring meeting workspace - get items from all meetings query.RowLimit = 10; //Will you have more than 10 duplicates? Increase this value query.ViewAttributes = "Scope='RecursiveAll'"; //Also return items from folders subfolders
注意:代码中可能存在一些错误,因为我是从头脑中写的
通过执行此查询,如果它返回多个项目,那么您有一个副本!
编辑:啊,对不起,你在谈论Web服务。
然后这段代码无济于事。 那么有两个选择:
选项1:您可以创建一个甚至可以从文件夹中包含项目的视图(平面视图)。 请参阅此处获取说明
选项2:根据列表Web服务的GetListItems方法,您可以传递QueryOptions参数。 通过
<QueryOptions> <MeetingInstanceID>-1</MeetingInstanceID> <!-- Again, if you query recurring meeting, you want ALL items --> <ViewAttributes Scope='RecursiveAll' /> <!-- or Recursive if that does not work --> </QueryOptions>
祝你好运!
Use SPList.Items doesn't return all items? Well, then try SPList.GetItems(SPQuery).
Have a following SPQuery:
SPQuery query = new SPQuery(); query.ViewFields = "<FieldRef Name='ID'/><FieldRef Name='Title'/>"; query.Query = String.Format("<Where><Eq><FieldRef Name='Title'/><Value Type='Text'>{0}</Value></Eq></Where>", someItemTitle) query.MeetingInstanceId = -1; //In case if you query recurring meeting workspace - get items from all meetings query.RowLimit = 10; //Will you have more than 10 duplicates? Increase this value query.ViewAttributes = "Scope='RecursiveAll'"; //Also return items from folders subfolders
Note: There could be some mistakes in code, because i`m writing from top of my head
By executing this query and if it returns more than one item, then you have a duplicate!
Edit: Ahh, sorry, you are talking about Web Services.
Then this code won't help. There are 2 options then:
Option 1: You CAN create a view that does include items even from folders (flat view). See here for instructions.
Option 2: According to Lists Web Service's GetListItems method, you can pass QueryOptions parameter. Pass in
<QueryOptions> <MeetingInstanceID>-1</MeetingInstanceID> <!-- Again, if you query recurring meeting, you want ALL items --> <ViewAttributes Scope='RecursiveAll' /> <!-- or Recursive if that does not work --> </QueryOptions>
Good luck!
相关问答
更多-
SharePoint 2007列出了webservice - 标识列表项的修订(SharePoint 2007 lists webservice - identify revision of list item)[2023-10-02]
通过“修订”,你的意思是版本? 如果是这样,你可能正在寻找这些属性之一: ows_owshiddenversion是一个整数(例如:8) ows__UIVersion是一个整数(例如:4096) ows__UIVersionString是一个字符串(例如:8.0) *编辑* 以下是使用文档库对其进行测试后的更多信息。 您还应该查看Hugo和Janis的其他评论,因为他们有一些很好的信息。 ows_owshiddenversion ows__UIVersion ows__UIVersionString ... -
我不知道为什么,但现在它的工作非常好。 我想维护团队在周末做了一些事,但我不知道是什么...... I can't tell why but it's just working perfectly fine right now. I suppose the maintenance team did somthing during the week-end but I don't know what...
-
嗨阅读公告列表项目在MSDN中演示( http://msdn.microsoft.com/en-us/library/office/hh185007(v=office.14).aspx )。 您的代码大多看起来像MSDN示例片段 - 这应该工作。 确保使用的是SharePoint网站的正确URL 确保您的列表名称正确拼写到JS代码中。 如果上述两者都已正确,请尝试在VS或Chrome调试器中调试代码。 I have found the solution for the above mentioned iss ...
-
看起来您可能需要在strBatch上添加一小部分( 使用本文作为参考 ):
New 这意味着你会有类似的东西: string strBatch =" "; 此外,如果列表中有任何必填字段,您可能还必须指定这些字段。 This is what I found that sol ...New Test -
使用SPList.Items不会返回所有项目? 好吧,然后尝试SPList.GetItems(SPQuery) 。 有一个以下的SPQuery: SPQuery query = new SPQuery(); query.ViewFields = "
"; query.Query = String.Format(" { ... -
您正在寻找SPField的FromBaseType属性。 如果该字段是List的原始模式的一部分,则此属性为true。 查看这篇优秀的SharePoint Exchange文章了解更多信息。 You are looking for the FromBaseType property of SPField. This property is true if the field is part of the original schema for the List. Check out this good Sh ...
-
是的,使用包含多种内容类型的列表。 您可以在网站级别定义自定义内容类型,并且可以在该网站和所有子网站中使用它们。 您可以在列表或库上启用内容类型,并为该列表或库包含多种内容类型。 您还可以在多个列表和库中拥有内容类型。 内容类型也可以相互继承。 所以,你可以有一个“基本议程”内容类型,并有其他内容类型从中继承。 内容类型不仅限于元数据,还涉及行为。 您可以将工作流分配到内容类型,并且在MOSS中您可以将策略(例如过期策略)分配给内容类型。 http://msdn.microsoft.com/en-us/li ...
-
我收到一个类似的错误消息,发现原因是我返回到BDC的数据是不可序的。 我必须修复我的Web服务以返回一些可序列化的数据(我认为String []是我使用的),它很好。 不完全相同,但也许它可以让你走上正确的道路。 I was getting a similar error message once and found out the reason was something regarding the fact that the data I was returning to the BDC was uns ...
-
好吧,omlin帮我解决了这个问题。 请看: https://sharepoint.stackexchange.com/questions/12652/get-total-size-of-attached-files-on-all-list-items-in-sharepoint-2007with-powersh 要使用界面检查大小,这很不错: http : //msmvps.com/blogs/shane/archive/2008/06/20/list-size-reporting.aspx ok, om ...
-
我不确定我使用的技术是否建议,但这解决了我的问题。 我的反馈链接在我的母版页面中被页脚管理,并且我在锚标记的href中附加了?Source = default.aspx。 例如 I am not sure if below technique that I used is recomended but this solved my problem. My Feedback link wa ...