SharePoint REST _api DateTimeRange查询(SharePoint REST _api DateTimeRange query)
我有一个包含数据类型
DateTime
开始日期和结束日期列表。 我想构造一个查询,以获取在查询日期范围内具有开始日期or
结束日期的所有事件。 问题是查询使用and
。 所以我只能在日期范围查询中获得开始和结束日期的事件。 我试图替换and
与or
但我只在控制台中获得Unexpected token
。 我看了文档 。 但解决不了。 有什么建议么?这是我的代码:
var DateRAngeFormat = 'YYYY-MM-DDT00'; var ThreeMonthsEarlier = moment().add(-3, 'months').format(DateRAngeFormat), ThreeMonthsFromNow = moment().add(3, 'months').format(DateRAngeFormat); var url = `${_spPageContextInfo.webAbsoluteUrl}/_api/web/lists/getbytitle('Program')/items?$select=Title%2CKontaktperson%2CBokning_x0020_till%2CBokning_x0020_fr_x00e5_n%2CMax_x0020_antal_x0020_platser%2CID&$filter=Bokning_x0020_fr_x00e5_n%20ge%20datetime'${ThreeMonthsEarlier}%3A00%3A00'%20and%20Bokning_x0020_till%20le%20datetime'${ThreeMonthsFromNow}%3A00%3A00'`;
EDIT
我使用CAML查询(服务器端代码)进行查询,得到我想要的结果。 所以我的猜测是可以使用REST _api,我只需要弄清楚如何。
var q = new CamlQuery() { ViewXml = "<View><Query><Where><Or><Gt><FieldRef Name='Bokning_x0020_fr_x00e5_n' /><Value IncludeTimeValue='TRUE' Type='DateTime'>2017-10-03T00:28:05Z</Value></Gt><Lt><FieldRef Name='Bokning_x0020_till' /><Value IncludeTimeValue='TRUE' Type='DateTime'>2010-04-02T00:28:08Z</Value></Lt></Or></Where></Query></View>"};
I have a list with start dates and end dates columns with the data type
DateTime
. I want to construct a query that fetches all events that have the start dateor
the end date within the query date range. The problem is that the query usesand
. So I only get events with start and end dates within the date range query. I tried replacing theand
withor
but I only getUnexpected token
in the console. I looked at the docs. But could not solve it. Any suggestions?This is my code:
var DateRAngeFormat = 'YYYY-MM-DDT00'; var ThreeMonthsEarlier = moment().add(-3, 'months').format(DateRAngeFormat), ThreeMonthsFromNow = moment().add(3, 'months').format(DateRAngeFormat); var url = `${_spPageContextInfo.webAbsoluteUrl}/_api/web/lists/getbytitle('Program')/items?$select=Title%2CKontaktperson%2CBokning_x0020_till%2CBokning_x0020_fr_x00e5_n%2CMax_x0020_antal_x0020_platser%2CID&$filter=Bokning_x0020_fr_x00e5_n%20ge%20datetime'${ThreeMonthsEarlier}%3A00%3A00'%20and%20Bokning_x0020_till%20le%20datetime'${ThreeMonthsFromNow}%3A00%3A00'`;
EDIT
I made a query using CAML query (serverside code) and I get the result I want. so my guess is that it is possible using the REST _api, I just have to figure out how.
var q = new CamlQuery() { ViewXml = "<View><Query><Where><Or><Gt><FieldRef Name='Bokning_x0020_fr_x00e5_n' /><Value IncludeTimeValue='TRUE' Type='DateTime'>2017-10-03T00:28:05Z</Value></Gt><Lt><FieldRef Name='Bokning_x0020_till' /><Value IncludeTimeValue='TRUE' Type='DateTime'>2010-04-02T00:28:08Z</Value></Lt></Or></Where></Query></View>"};
原文:https://stackoverflow.com/questions/48067562
最满意答案
好的想出了一个适合我使用ssh的方法。
将本地项目.git文件夹复制到远程服务器目录上的项目。 您可能必须复制到具有正确权限的文件夹,然后移动.git文件夹
scp /local/path/to/.git user@remote:/remote/path/to/temp/folder
更改.git的所有权并将其移动到现有项目目录
chown -R www-data:www-data .git/ mv .git/ /var/www/....
执行git状态会显示已更改的文件和未跟踪的文件。 在我的情况下,'更改'文件是我想要覆盖的旧文件,以及我在.gitignore中指定的文件的未跟踪文件。
所以要将文件“恢复”到分支中的新版本(存储在.git文件夹中)并忽略未跟踪的文件,我只是做了
git checkout .
这也添加了.gitignore文件,我也不得不说。
这是在一个只有一个主分支的项目上测试的,但我希望这有助于未来的人们。 我的术语可能稍微有点描述git进程,但希望每个人都能了解情况。
Ok figured out a method that worked for me using ssh.
Copy the local projects .git folder to the project on the remote servers directory. You may have to copy to a folder with correct privileges then move the .git folder
scp /local/path/to/.git user@remote:/remote/path/to/temp/folder
Change the ownership of the .git and move it to the existing projects directory
chown -R www-data:www-data .git/ mv .git/ /var/www/....
Performing a git status shows the changed files and untracked files. In my case the 'changed' files were the old files I wanted to overwrite, and the untracked files where the files I specified in .gitignore.
So to 'revert' the files to the new versions in the branch (stored in the .git folder) and ignore the untracked files, I just did
git checkout .
This also added the .gitignore file, which I had to
chown
too.This was tested on a project with only a master branch, but I hope this helps people in the future. My terminology may be a little off describing the git processes but hopefully everyone gets the picture.
相关问答
更多-
没有项目文件夹的git克隆(git clone without project folder)[2022-05-01]
git clone接受最后一个参数是目标目录,默认情况下是项目名称,但可以更改它。 在你的情况下,你可能很简单. : $ git clone origin-url . 但是请注意,从man git-clone : 只有当目录为空时才允许克隆到现有目录。 git clone accepts a last argument that is the destination directory, it is by default the name of the project but you can change ... -
实际上git v.1.7.0似乎确实存在foldernames的问题。 使用此.git / info / sparse-checkout实际上可以正常工作 include/ htdocs/* !htdocs/downloads/ !htdocs/images/ !htdocs/videos/ 因此,我的Mac上不需要使用较新的Git版本,但在具有较旧Git的Linux服务器上不需要尾部斜杠。 Actually git v.1.7.0 does seem to have problems with fold ...
-
“git clone”到现有文件夹中的最佳做法是什么?(What's the best practice to “git clone” into an existing folder?)[2022-03-22]
这可以通过克隆到新目录,然后将.git目录移动到现有目录中。 如果您现有的目录命名为“代码”。 git clone https://myrepo.com/git.git temp mv temp/.git code/.git rm -rf temp 这也可以在克隆命令期间不执行检出来完成; 更多的信息可以在这里找到。 This can be done by cloning to a new directory, then moving the .git directory into your existi ... -
好的想出了一个适合我使用ssh的方法。 将本地项目.git文件夹复制到远程服务器目录上的项目。 您可能必须复制到具有正确权限的文件夹,然后移动.git文件夹 scp /local/path/to/.git user@remote:/remote/path/to/temp/folder 更改.git的所有权并将其移动到现有项目目录 chown -R www-data:www-data .git/ mv .git/ /var/www/.... 执行git状态会显示已更改的文件和未跟踪的文件。 在我的情况下, ...
-
克隆项目一个接一个: git svn clone -s https://remote-svn/svn/project/Project1 git svn clone -s https://remote-svn/svn/project/Project2 git svn clone -s https://remote-svn/svn/project/Project3 … Clone projects one by one: git svn clone -s https://remote-svn/svn/proj ...
-
虽然可以使用sudo并定义特定的命令,但我建议不要这样做:这个设置听起来容易错误配置或破坏。 我建议你每隔几分钟就有一个cron工作运行git pull 。 While it is possible using sudo and defining specific commands, I'd recommend against it: This setup sounds easy to misconfigure or break. I'd recommend that you have a cron job ...
-
一种选择是将目录CCC放入其自己的存储库中,然后使用git submodule将其添加回Repo1和Repo2。 如果需要保留其历史记录,可以使用git filter-branch从历史记录中将CCC从Repo2提取到自己的存储库中。 One option is to put the directory CCC into its own repository, and then use git submodule to add it back into Repo1 and Repo2. You can ex ...
-
Git项目中的子文件夹?(Sub folder in Git project?)[2023-07-31]
克隆git存储库时,您始终会克隆整个存储库。 如果您想在项目中使用子文件夹,只需创建它们即可。 只要你在里面添加文件(git只跟踪没有文件夹的文件 - >如果一个文件夹是空的,你不能将它添加到你的repo中),它们可以通过提交里面的文件来提交到你的版本库。 I found an answer: http://blog.quilitz.de/2010/03/checkout-sub-directories-in-git-sparse-checkouts/ I had git 1.5.5, and it req ... -
开始在现有项目中使用Eclipse GIT ...项目文件被移动(Start using Eclipse GIT with an existing project … project files get moved)[2022-12-21]
我发现文件确实被移动了。 我需要关闭所有打开的项目文件,然后再次从包资源管理器打开它们(这将从git存储库打开文件)。 I found out that the files really get moved. I needed to close all the open project files and then open them from package explorer again (which will open the files from git repository). -
如果您正在使用Composer,并且没有特殊要求将依赖项包含在您自己的存储库中,我认为遵循Composer开发人员的建议不要在您自己的存储库中包含vendor文件夹是一个好主意,但只添加并提交composer.lock文件。 将行vendor/添加到最顶层目录中的.gitignore文件中,基本完成。 更多信息: https : //getcomposer.org/doc/faqs/should-i-commit-the-dependencies-in-my-vendor-directory.md If y ...