How do we write gremlin update/modify query in node.js? - node.js

How do we write gremlin update/modify query in node.js ?
I want to update particular field and save the same and do not modify other fields which are not edited.
I have a table called "org" and it has some properties like name, id, label.
How can we modify particular property or all the properties depends on the put body request ? using gremlin query

Any property can be updated as follows (assuming it is a single value and not a set)
g.V('some-id').
property(Cardinality.single,'my-property',new-value).
iterate()
UPDATED: If you need to update the contents of multiple properties you can just chain the property steps together.
g.V('some-id').
property(Cardinality.single,'p1',new-value).
property(Cardinality.single,'p2',new-value).
property(Cardinality.single,'p3',new-value).
property(Cardinality.single,'p4',new-value).iterate()
UPDATED again
If you only want to set a property value if the property already exists you can check for its existence using a 'has' step as shown below.
g.V('some-id').
has('p1').
property(Cardinality.single,'p1',new-value)
If you want to do this for more than one property you can use optional steps as one way to do multiple of these checks.
g.V('some-id').
optional(has('p1').
property(Cardinality.single,'p1',new-value)).
optional(has('p2').
property(Cardinality.single,'p2',new-value)).
Some additional information can be found at [1] and [2]
[1] http://www.kelvinlawrence.net/book/PracticalGremlin.html#addnodes
[2] https://tinkerpop.apache.org/docs/current/reference/#addproperty-step

Related

Find all resources (users) that has a schema extension property set to null

We have a scenario were we need to extend the existing schema in AAD for users to support our use case. As soon as a new user has been created (we do not control this process) we want to attach some additional information to the object. We also want to attach information to all the already existing user objects. We though the schema extension in the Graph API would solve this issue for us.
I've added a schema definition based on the tutorial here. Our extension got the name ext7sumrsqd_policies and have the following properties:
IsHandled (boolean)
SuggestedOwner (string)
After the extension was created I wanted to find all users that does not have the new "property" set (imagine a sync that is running on an intervall and want to check for new users that has not yet been handled).
Tried the following query first: https://graph.microsoft.com/v1.0/users?$filter=ext7sumrsqd_policies eq null
However the Graph API does not support filter with null.
Therefore tried to filter on any of the properties on the new extension:
https://graph.microsoft.com/v1.0/users?$filter=ext7sumrsqd_policies/IsHandled eq false
https://graph.microsoft.com/v1.0/users?$filter=ext7sumrsqd_policies/IsHandled eq true
However this filter never returns any user that has ext7sumrsqd_policies=null.
Are there any way you can filter the Graph API for resources that is currently missing a schema extension property or where the property is null?
As stated filtering by null is not supported. You might try creating a second schema extension such as ext7sumrsqd_hasPolicies that specifies if ext7sumrsqd_policies is null or not.

Can I create azure cosmos db document with a custom key other than Id

I am using azure cosmos db for saving and editing my session information. Currently i am not using ID in my document, instead i have another unique field with all docs. How can i update my query to get documents?
You can use whatever property you want, for your custom key (just make sure you don't remove its index). By default, all properties are indexed unless you explicitly set up a custom index policy that removes certain properties from being indexed.
You cannot eliminate the built-in id property though; if you don't set it explicitly, it will just be set to a guid.
If you are doing queries, this really shouldn't matter, functionality-wise. Just search on whatever properties you want. However: If you are doing point-reads (a read is more efficient, RU-wise, than a query, when retrieving a single document) you can only perform a point-read by specifying the id property, not your custom property. If you must use a custom property and you need to do point-reads, you can consider storing your custom property as id as well (as long as it's guaranteed to be unique per document).

Set values in workorder created from Asset in Maximo

I would like to create work order using escalation once the asset is moved to some other location (like REPAIR) using move/modify. I do understand that we can trigger CREATEWO however I am not sure on how to set the values on some fields in work order like worktype, workact , etc. Also I am unable to pick the correct record which has performed move modify ( unable to fetch the exact record using ASSETTRANS table).
Let me know if anyone has done this before, thanks in advance!
It sounds like you have an Escalation calling an Action that calls the AppAction CREATEWO. Assuming that's correct..
First, create a Relationship in DB Config between the ASSET object and WORKORDER that will find the most recent work order against this asset. You can look at the NEWWORKORDER relationships on WORKORDER and TICKET as an example. For reference, I will assume you name this relationship MYNEWWORKORDER.
Next, create some Actions against the ASSET object that use MYNEWWORKORDER.<ATTRIBUTENAME> in the Parameter/Attribute field, where <ATTRIBUTENAME> is the name of the attribute (e.g. WORKTYPE) you want to supply a value for in the Value field.
Once that is done, create an Action of type Action Group where CREATEWO is the first member and the Actions you just made are the succeeding members.
Finally, update the Escalation to call your new Action Group instead of the numbered one that the Escalation application created for you.

CQ5 QueryBuilder if Property has a value or has no value

I am running a query like to do determine if the page has the given tag(s)
predicates.put("property","jcr:content/cq:tags");
predicates.put("property.and","true");
predicates.put("property.1_value","properties:style");
predicates.put("property.2_value","properties:style/color");
I also want to be able to get all results that have any tag or query on all results that have no tag.
What would I put in the value section to check for these constraints
You need to set the operation parameter of the property predicate. Its semantic is described here: JcrPropertyPredicateEvaluator

How to index documents with elastic.js client?

So far I haven't found any samples of HOW the elastic.js client api (https://github.com/fullscale/elastic.js) can be used for indexing documents. There are some clues here & there but nothing concrete yet.
http://docs.fullscale.co/elasticjs/ejs.Document.html
Document ( index, type, id ): Object used to create, replace, update, and delete documents
Document > doIndex(fnCallBack): Stores a document in the given index and type. If no id is set, one is created during indexing.
Document > source (doc): Sets the source document.
Can anyone provide a sample snippet of code to show how an document object can be instantiated and used to index data?
Thanks!
Update # 1 (Sun Apr 21st, 2013 on 12:58pm CDT)
https://gist.github.com/pulkitsinghal/5430444
Your gist is correct.
You create ejs.Document objects specifying the index, type, and optionally the id of the document you want indexed. If you don't specify an id, elasticsearch will generate one for you.
You set the source to the json object you want indexed then call the doIndex method specifying a callback if needed. The node example does not index docs, but the angular and jquery examples show a basic example and can easily be used with the node client.
https://github.com/fullscale/elastic.js/blob/master/examples/angular/js/controllers.js#L30
Also have a peek at the tests:
https://github.com/fullscale/elastic.js/blob/master/tests/index_test.js#L265
elastic.js nowadays only implements the Query DSL, so it can't be used for this scenario anymore. See this commit.

Resources