Domino 访问视图是否可以接受视图选择条件
Can a domino access view accept view selection criteria
如果使用 Domino Access View 作为 REST 调用来访问数据库视图,是否可以将视图选择参数作为 URL 查询字符串的一部分传递,特别是接受日期范围?这是为了将结果限制为某些标准?
我看过 'keys' 和 'keysmatch' 参数,但这对范围选择问题没有帮助。
怀疑没有,只是想要一些专家反馈!
据我所知这是不可能的。您可以使用查询参数来检索与您提交的搜索查询相匹配的文档(执行 domino ftsearch)。
可以在此处的文档中找到更多详细信息:View/folder entries GET
您可以轻松地在 Domino 服务器上编写自己的 REST API 并让它接受例如日期范围。
我在此处的演示文稿中有这方面的示例:http://blog.texasswede.com/my-connect-2016-presentation-demo-database/
这是构成 REST 调用的服务器代理的 Lotusscript 代码:
Use "Class.URL"
Use "Class.JSON"
Sub Initialize
'*** Local Notes classes used in agent
Dim session As New NotesSession
Dim db As NotesDatabase
Dim thisdb As NotesDatabase
Dim view As NotesView
Dim col As NotesViewEntryCollection
Dim entry As NotesViewEntry
Dim doc As NotesDocument
'*** Custom classes
Dim url As URLData
Dim json As JSONData
'*** Local variables to hold arguments passed from URL
Dim startdate As String
Dim enddate As String
'*** Other local variables
Dim jsontext As String
'*** Create new URLData object
Set url = New URLData()
'*** Create new JSONData object
Set json = New JSONData()
'*** Check start date and convert from ISO to US date format
If url.IsValue("start") Then
startdate = ISOtoUS(url.GetValue("start"))
Else
startdate = "01/01/1980"
End If
'*** Check end date and convert to US date format
If url.IsValue("end") Then
enddate = ISOtoUS(url.GetValue("end"))
Else
enddate = "12/31/2199"
End If
'*** Send MIME header to browser
Print "content-type: application/json"
jsontext = ""
Set db = session.CurrentDatabase
Set view = db.GetView("Events")
Set col = view.AllEntries
Set entry = col.GetFirstEntry()
Do Until entry Is Nothing
If CDat(entry.ColumnValues(0))>=CDat(startdate) Then
If CDat(entry.ColumnValues(0))<=CDat(enddate) Then
Call json.SetValue("id", CStr(entry.ColumnValues(5)))
Call json.SetValue("title",CStr(entry.ColumnValues(3)))
Call json.SetValue("start", Format$(CDat(entry.ColumnValues(7)),"mm/dd/yyyy hh:nn ampm"))
Call json.SetValue("end", Format$(entry.ColumnValues(8),"mm/dd/yyyy hh:nn ampm"))
Call json.SetValue("className","eventData eventData" + CStr(entry.ColumnValues(6)))
Call json.NoStatus()
'*** Make the entry editable (change date/time)
Call json.SetBoolean("editable", True)
End If
End If
jsontext = jsontext + json.GetJSON() + "," + Chr$(13)
Set entry = col.GetNextEntry(entry)
Loop
If Len(jsontext)>4 Then
jsontext = Left$(jsontext,Len(jsontext)-2)
End If
Print "[ " + jsontext + " ]"
End Sub
%REM
Function ISOtoUS
Description: Convert ISO date to US date,
e.g 2015-05-08 to 05/08/2015
%END REM
Function ISOtoUS(dateISO As String) As String
Dim tmp As String
' 2015-02-03
tmp = Mid$(dateISO,6,2) + "/"
tmp = tmp + Mid$(dateISO,9,2) + "/"
tmp = tmp + Left$(dateISO,4)
ISOtoUS = tmp
End Function
注意它使用了我写的两个助手 类,你也可以在我的博客上找到它们的代码:
http://blog.texasswede.com/free-code-class-to-read-url-name-value-pairs/
和
http://blog.texasswede.com/calling-a-notes-web-agent-from-another-server-using-jsonp/
如果使用 Domino Access View 作为 REST 调用来访问数据库视图,是否可以将视图选择参数作为 URL 查询字符串的一部分传递,特别是接受日期范围?这是为了将结果限制为某些标准?
我看过 'keys' 和 'keysmatch' 参数,但这对范围选择问题没有帮助。
怀疑没有,只是想要一些专家反馈!
据我所知这是不可能的。您可以使用查询参数来检索与您提交的搜索查询相匹配的文档(执行 domino ftsearch)。
可以在此处的文档中找到更多详细信息:View/folder entries GET
您可以轻松地在 Domino 服务器上编写自己的 REST API 并让它接受例如日期范围。
我在此处的演示文稿中有这方面的示例:http://blog.texasswede.com/my-connect-2016-presentation-demo-database/
这是构成 REST 调用的服务器代理的 Lotusscript 代码:
Use "Class.URL"
Use "Class.JSON"
Sub Initialize
'*** Local Notes classes used in agent
Dim session As New NotesSession
Dim db As NotesDatabase
Dim thisdb As NotesDatabase
Dim view As NotesView
Dim col As NotesViewEntryCollection
Dim entry As NotesViewEntry
Dim doc As NotesDocument
'*** Custom classes
Dim url As URLData
Dim json As JSONData
'*** Local variables to hold arguments passed from URL
Dim startdate As String
Dim enddate As String
'*** Other local variables
Dim jsontext As String
'*** Create new URLData object
Set url = New URLData()
'*** Create new JSONData object
Set json = New JSONData()
'*** Check start date and convert from ISO to US date format
If url.IsValue("start") Then
startdate = ISOtoUS(url.GetValue("start"))
Else
startdate = "01/01/1980"
End If
'*** Check end date and convert to US date format
If url.IsValue("end") Then
enddate = ISOtoUS(url.GetValue("end"))
Else
enddate = "12/31/2199"
End If
'*** Send MIME header to browser
Print "content-type: application/json"
jsontext = ""
Set db = session.CurrentDatabase
Set view = db.GetView("Events")
Set col = view.AllEntries
Set entry = col.GetFirstEntry()
Do Until entry Is Nothing
If CDat(entry.ColumnValues(0))>=CDat(startdate) Then
If CDat(entry.ColumnValues(0))<=CDat(enddate) Then
Call json.SetValue("id", CStr(entry.ColumnValues(5)))
Call json.SetValue("title",CStr(entry.ColumnValues(3)))
Call json.SetValue("start", Format$(CDat(entry.ColumnValues(7)),"mm/dd/yyyy hh:nn ampm"))
Call json.SetValue("end", Format$(entry.ColumnValues(8),"mm/dd/yyyy hh:nn ampm"))
Call json.SetValue("className","eventData eventData" + CStr(entry.ColumnValues(6)))
Call json.NoStatus()
'*** Make the entry editable (change date/time)
Call json.SetBoolean("editable", True)
End If
End If
jsontext = jsontext + json.GetJSON() + "," + Chr$(13)
Set entry = col.GetNextEntry(entry)
Loop
If Len(jsontext)>4 Then
jsontext = Left$(jsontext,Len(jsontext)-2)
End If
Print "[ " + jsontext + " ]"
End Sub
%REM
Function ISOtoUS
Description: Convert ISO date to US date,
e.g 2015-05-08 to 05/08/2015
%END REM
Function ISOtoUS(dateISO As String) As String
Dim tmp As String
' 2015-02-03
tmp = Mid$(dateISO,6,2) + "/"
tmp = tmp + Mid$(dateISO,9,2) + "/"
tmp = tmp + Left$(dateISO,4)
ISOtoUS = tmp
End Function
注意它使用了我写的两个助手 类,你也可以在我的博客上找到它们的代码: http://blog.texasswede.com/free-code-class-to-read-url-name-value-pairs/ 和 http://blog.texasswede.com/calling-a-notes-web-agent-from-another-server-using-jsonp/