Please help me with the query on Gremlin lang
I have a graph with 2 types of vertices: User and Group.
I need to find friends of 'U1'. If users have edges ( member or invite ) to 'Group A' need to flag them like the below result.
Expected result : [ { U2: 'Member'}, { U3: 'Invited' }, { U4: 'Member'} ]
You can start from the vertex of U1 and from there you can go to all his friends using out step, then filter them with where step.
g.V().hasLabel('U1').out('Friend').
where(out('Member', 'Invited').
hasLabel('Group A'))
example: https://gremlify.com/1o0chgjomi6/1
EDIT
for this type of result you can do:
g.V().hasLabel('U1').out('Friend').
as('friend').
outE('Member', 'Invited').where(inV().
hasLabel('Group A')).
group().
by(select('friend').label()).
by(label())
example: https://gremlify.com/4qnd7wi1rnv
g.V().has('User', 'name', 'U1')
.out('friend')
.as('friends')
.bothE('invited', 'member', 'friend')
.where(or(inV().has('Group', 'name', 'G1'), outV().has('User', 'name', 'U1')))
.group()
.by(select('friends').values('name'))
.by(label().fold())
Related
How to create a function in TypeORM to find an data by time range in OneToMany entity?
I create an where clause to find:
const users = await this.conn
.getRepository(User)
.find({
select: ['id', 'firstName', 'lastName', 'sex', 'birthdate', 'subAddress', 'address', 'city', 'district', 'disabilityType'],
join: {
alias: "user",
leftJoinAndSelect: {
order: "user.orders"
}
},
where: {
order.createdAt: Between(dto.from, dto.to)//HERE
}
});
but it not work and always throw me NOT_FOUND :/
can someone show how this should be?
You are trying to get the results based on filter for the child record and I am not sure if it works with typeorm(based on my experience with other language).
However I found some articles on GitHub which may help you.
An alternative solution link:
here
Bug reported and in status open:here
I hope it guides you somehow
I ran into a little problem with my firebase queries.
I want to get all series with episodes that i haven't watched yet. At the moment i load them all from firebase and use the filter function in JavaScript. But i would like to minimize the Data Download from firebase a bit.
So i only want the get the series that match this dummycode criteria:
ref("series").orderByChild("seasons/*/episodes/*/episodeWatched").equalTo(false)
This is a small output of my structure in firebase
series >
<unique series id>
seriesName: string
seasons >
seasonCount: number
<season nummer>
episodes >
<episode number>
episodeName: string
episodeWatched: boolean
episodeAirDate: Date
a more "real" exampel would be:
{ series:
[{ 123456:
{ seriesName: "Mr Robot",
seasonCount: 3,
seasons:
[{ 0: episodeCount: 10,
episodes:
[{ 0:
{ episodeName: "Eps1.0_hellofriend.mov",
episodeWatched: true,
episodeAirDate: 27-05-2015 }
{ 1:
{ episodeName: "Eps1.1_ones-and-zer0es.mpeg",
episodeWatched: false,
episodeAirDate: 01-07-2015 }
...
}]
...
}]
}
}]
}
I have a problem with this "wildcards" in my dummycode above, i get only the values of specific nodes, and i can't concat the "orderByChild" function.
If i could concat the function, my aproach to this would be like:
ref("series").orderByChild("seasons").orderByChild("episodes").orderByChild("episodeWatched").equalTo(false)
At the moment i tried several things with wildcards or anything like that, the only thing that works at the moment is:
ref("series").orderByChild("seasons/0/episodes/0/episodeWatched").equalTo(false)
but this only checks: is the first episode of the first season checked.
Did anyone had this problem yet?
I think this is one of those times you duplicate / restructure your db to optimize for reads.
user/uid/notWatched: {
"showId_seasonId_epId": true
}
I want to create an custom search using Suite Script 2.0 version with the Filter Condition as an Formula Date Field with NVAL2 Function
I'm achieving this search on the UI as Saved Searches but i want create it on the Code itself.
Search Filter Created on the UI(Saved Search):
My Code:
var mySearch = search.create({
type: 'customrecord_configuration',
columns: ['custrecord_supervisor'],
filters: [
[
[
['custrecord_from_date', 'greaterthanorequalto', fromDate], 'AND', ['Formula Date', 'lesserthanoreqaulto', NVL2({
custrecord_end_date
}, {
custrecord_end_date
}, TO_DATE('01/01/2200', 'MM/DD/YYYY'))]
]
]
]
});
Thanks in Advance.
The internal ID for a Formula (Date) column would be formuladate, and your formula value needs to be a String:
[
'formuladate', 'lesserthanoreqaulto',
"NVL2({custrecord_end_date}, {custrecord_end_date}, TO_DATE('01/01/2200', 'MM/DD/YYYY'))"
]
If you use Chrome, you can also try this Chrome Extension that lets you export UI searches directly to code.
So I a using the node paypal-rest-sdk module and I'm trying to create a billing plan. Using the documentation here I made this JSON:
const billingPlanAttributes = {
name: 'Subscription',
description: 'Monthly subscription plan',
type: 'INFINITE',
payment_definitions: [{
name: 'Regular monthly infinite payments',
type: 'REGULAR',
frequency_interval: '1',
frequency: 'MONTH',
cycles: '0',
amount: {
currency: 'USD',
amount: '4.99',
},
}],
merchant_preferences: {
cancel_url: 'http://localhost:3000/subscribe/cancel',
return_url: 'http://localhost:3000/subscribe/return',
auto_bill_amount: 'YES',
},
};
But when using the paypal.billingPlan.create(... function I get the error 'MALFORMED_REQUEST', 'Incoming JSON request does not map to API request'. So I guess my JSON is not in the correct format or I'm missing something that is need.
The documentation has a charge_models key but it does not mention that it is required unlike other keys.
If you can point me in the right direction that would be great.
Edit: changed the return url and cancel url to include the full domain but still same error.
There could be more to this, but I noticed one thing wrong with your JSON. Remove commas for items last in a list. After 'amount' and 'merchant_preferences'. JSON is picky.
late answer, I know, but ran in exactly the same issue than you.
In the create function of the billing plan
public function create($apiContext = null, $restCall = null)
{
$payLoad = $this->toJSON();
$json = self::executeCall(
"/v1/payments/billing-plans/",
"POST",
$payLoad,
null,
$apiContext,
$restCall
);
$this->fromJson($json);
return $this;
}
I found out, that the toJSON method always returned false. Why the hell!?!
I did the same as you did and copied the complete sample code into my code. Then it worked as expected. Now I checked, what the difference was in to my code.
I realized, that I used an umlauts (ä,ü,ö) in the name and description of the billing plan. I changed the umlauts to
'ä' => 'ae',
'ö' => 'oe'
'ü' => 'ue'
Then it worked fine! Maybe someone else is running in this issue, too.
I have the following code in my /search/:query route:
var param = {
query: req.query['query']
}
MyModel.find({
"$or": [
{ 'name': req.param.query },
{ 'age': req.param.query },
{ 'event': req.param.query },
]
}, function (err, results) {
if (err) {
console.log(err)
}
else {
res.render('index', {
data: results
});
}
}
);
And is good, i can search for pretty much every data that i want, but only individually. What if i want search name + age, can i? Example: 'Leo 22'.
There is any way that mongoose help me with this?
UPDATE:
My problem is:
I have tables lists it titles, this title is the concatenation of 'eventName' and 'eventDate'.
Real examples of this fields:
'Special Event - 20/12/2015'
'Classic Event - 12/03/2015'
'Hot Summer Event - 05/07/2005'
Every week will be create 4 events. In some point, a user will search for an old event, and i believe that the user will search in this format:'EVENT NAME - EVENT DATE'..
So i need a way to bind this values in my controllers.
I'm no familiar with mongoose but in order to do that, you must have a way to bind your query param to the attribute you want to search. Otherwise, they wouldn't know Leo is name and 22 is age.
Ur path would be like search?name=:name&age=:age&event=:event and in your code, you will have to process like if the param is not null, add and condition to it.
It seems you are using only one parameter (req.param.query) to filter all attributes. That's not mongoose related: you could create distinct parameters for each attribute and pass them along the query string.
For instance:
"$or": [
{ 'name': req.param.name },
{ 'age': req.param.age },
{ 'event': req.param.event },
]
And your HTTP request will be like this:
http://youraddress/expressRoute?name=Leo&age=22