I have a few million nodes large data set imported with https://github.com/jexp/batch-import .
Unfortunately, the script made relationship property names space separated as in "Some Property".
How do I ask for this property in Cypher?
As expected
r.Some Property
does not work, which is only fair.
I also tried:
r["Some Property"]
Is there a syntax for such naming?
Should I just redo the import with camel case property names or underscore separated ones?
You can return properties with spaces in the names by using backticks, `, to enclose the property name. Something like this should work in Cypher:
START r=rel(0) RETURN r.`Some Property`;
This goes for node properties as well.
you can use MATCH (r) WHERE r.type=~'Some Property.*' RETURN r;
I hope this will get you exact relation-type.
OR
MATCH (n)-[r]->() WHERE type(r)=~'S.*' It will give you all relationship started with S.
Related
I have a collection of slugs and want to get each corresponding page with one query.
Something like ...
Page::whereIn('slug', $slugs)->get();
... does only return the first page matching any slug in the collection.
Currently there is a loop, but that are dozens of queries I want to avoid.
Try using the whereRaw method and imploding your array into a string:
Page::whereRaw('slug IN ("' . $slugs->implode('","') . ')')->get();
As it turned out, whereIn was the right way. There was one minor mistake in my logic, and at the same time insufficient seeding data, that blowed everything up.
If someone does not know: whereRaw should be used with caution. To avoid SQL injection vulnerability, all user-submitted entries have to be passed as parameters.
Page::whereRaw('slug IN (?)', [$slug]);
Beware: Wrapping ? with quotes is a syntax error. The passed data will be single-quoted by default, at least on my machineā¢.
select * from `pages` where `slug` in ('page');
I cannot seem to find anything about using the values of one property of an object in a foreach loop (without having the entire object placed into the loop).
I first create a function called UFGet-Servers that uses Get-ADComputer and returns the names of the servers in a specific OU in my environment and places them in an array. That's great, except that when I use the array in a foreach loop, each object that it grabs has #[Name=serverName] in it, which I cannot use in any useful manner. The following pseudo-code is an abbreviated example:
foreach($Computer in $ComputerNames){do code... code is adding the server name into a UNC path such as "\\$Computer\C$\"}
The problem with the above is that you can't add the whole object to a path -- it ends up looking like "\#[Name=serverNameHere]\C$\" which totally bombs out. How do I get rid of the "#[property=" part, and simply use the value as the $Computer in the loop?
What really weirds me out is that I can't find a straightforward article on this anywhere... would have thought everyone and their mom would have wanted to do something like this.
So, your issue isn't with ForEach loops, it is with string formatting. There are two ways that I know of to take care of what you need. First is going to be string formatting, which allows you to use {0}m {1} and so on to inject values into a string, providing that you follow the string with -f and a list of said values. Such as:
ForEach($Computer in $ComputerNames){
"The Server Path is \\{0}\Share$" -f $Computer.Name
}
The second way is a sub-expression (I'm sure somebody will correct me if I used the wrong term there). This one involves enclosing the variable and desired property (or a function, or whatever) inside $(). This will evaluate whatever is inside the parenthesis before evaluating the string. See my example:
ForEach($Computer in $ComputerNames){
"The Server Path is \\$($Computer.name)\Share$"
}
On my application i have to search for an alphanumeric id which return one or more rows of data. On each of these rows a link is present i have to click on the first link.
Unfortunately it doesn't have any unique properties so i cannot add it to the OR. Instead i used descriptive programming something like below
'returns false
page.Link("class:=ng-binding","innertext:=AplhaID","html tag:=A").Exist
QTP fails to identify the object with the above code. So Instead of this i tried using Description object something like the below code
Set oDesc = Description.Object
oDesc("class").Value = "ng-binding"
oDesc("html tag").Value = "A"
oDesc("innertext").Value = "AplhaID"
Set lnk = page.ChildObjects(oDesc)
'gives me 2 which is correct. There are two links
msgbox lnk.Count
'highlights the correct link
lnk(0).Highlight
I do not know what could be causing this behavior. I thought is could be because multiple links match the description but I perform this search for multiple ids and eventhough multiple rows are returned the descriptive programming code is able to identify the correct row and proceed.
I looked at QTP descriptive programming issue but my link's property values do not have special characters.
In order to use Descriptive string method, ensure that you have only one object matching the given properties.
Below statement might fail if there are more than 1 object with the given properties.
page.Link("class:=ng-binding","innertext:=AplhaID","html tag:=A").Exist
So , you need to make the statement to find an object uniquely. Try this. It will work!
page.Link("class:=ng-binding","innertext:=AplhaID","html tag:=A", "index:=0").Exist
I would like to filter a ng-repeat list of items with multiple catgories checkboxes.
i read this Filtering by multiple checkboxes in AngularJS and watched the videos by Egghead, but i have an error on a simple for loop and i don't understand:
ReferenceError: i is not defined
here is a plunker with the code : http://plnkr.co/edit/p538ALfs00JTFQ6mKT9j
thank you for your help
If you're going to use strict mode ('use strict';), you need to declare your variables. Your checkboxFilter uses many variables that are never defined (i included). You can get past the your initial issues by changing script.js:22-23 to:
var i,j,k,filter_cat,filter_value,filter_name,matchingItems = [];
You have three other problems after that...
Line 37, This code is looking for a property named filter_cat: items[i].filter_cat, when what you wanted was to look for a property name with the value of filter_cat, so this is what you want: items[i].[filter_cat].
Your json data has lowercase field names and your code is searching on uppercase (Type vs type)
Your json data has lowercase values and your code is searching on uppercase (Fruit vs fruit)
Here is a partial edit that gets you on the right track. You'll still need to modify your json or compare lowercase (I partially modified your json): http://plnkr.co/edit/d7p4QthXJg4ao34ATWla?p=preview
I am attempting to set the Name property of a Page in the constructor:
public partial class PageListView : Page
{
public PageListView(string title)
{
InitializeComponent();
Name = title;
}
}
However, I often get the following error message.
'x' is not a valid value for property 'Name'.
Where x seems to be almost anything, drilling down into the exception details doesn't seem to provide any useful information (e.g. the InnerException is null.)
Does anyone know what is happening here?
The Name property generally follows the rules of C#/VB.NET identifiers (i.e. fields). Based on the documentation:
The string values used for Name have some restrictions, as imposed by
the underlying x:Name Directive defined by the XAML specification.
Most notably, a Name must start with a letter or the underscore character
(_), and must contain only letters, digits, or underscores.
Based on the parameter you are passing (i.e. title), it seems like you may violate that. But you'd have to give some specific examples to be sure.
Of course, moments after posting this I realised what's going on.
Because FrameworkElement.Name is used for creating object references, you have to ensure that the string contains only valid chars for an object instance variable name.
Use Title or another plain text property instead, unless you really want to set the x:Name property for referencing.