How to add custom property with mongoose ref - node.js

I'm trying to add custom property 'priority' so that I can map my Field collection with the Attribute collection. Here
To get output like this one But with priorities after attribute_name

Related

How do we write gremlin update/modify query in 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

Question about the [PXDimension] attribute

If I set up my own segmented key ID to be used with a custom DAC's identity field, Do I need anything else other than the [PXDimension] attribute on that DAC field to implement the enforcement of that segment setup?
You would have to define your custom field with the [PXDimensionSelector] attribute.
When this attribute is used, the first parameter should be the dimension name (defined in the Segmented Keys page - CS202000), followed by the ID value (this is the value persisted in the DB), and then the CD value (this is the user-friendly value).
For instance, the Item Class Dimension selector can be defined like this:
[PXDimensionSelector(INItemClass.Dimension,
typeof(Search<INItemClass.itemClassID, Where<INItemClass.stkItem, Equal<False>>>), typeof(INItemClass.itemClassCD), DescriptionField = typeof(INItemClass.descr))]
When the value is then added to the UI, the framework will recognize the Dimension-selector attribute and it will create it as a PXSegmentMask field instead of a regular PXSelector

Can l use PowerShell to update the property of entity in azure storage to null

I have retrieved an entity from my table. I want to set one of the property to null. Can I do that?
Simple answer is No. You can't set a property's value to null.
Essentially Azure Table is a key/value pair storage. An entity contains attributes and each attribute must have a name, type and value and the value can't be null.
One thing you could do is remove that particular attribute from the entity. The approach for that would be:
Fetch the entity.
Remove the attribute from the entity for which you want to set the value to null.
Update the entity.

Pre-allocation of attributes by creating new entity

While creating new entity in CRM, some fields will be pre-allocated. Exmaple: for a new contact - transactioncurrency and ownerid will be filled with values. Haw can I programmatically find out, which rules will be used for such pre-allocation. I can't call "initializefromrequest" to find it out, because I want to build offline DB and there apply the rules
thanks
Get the EntityMetadata for your entity then examine AttributeMetadata for each Attribute to determine if the IsCustomAttribute Property is true
Retrieve Entity metadata using EntityFilters = EntityFilters.Attributes
Iterate the Attribute collection of the EntityMetadata in the response
Check the IsCustomAttribute property on each AttributeMetadata

Mongoose create custom _id from other fields

I know that Mongoose populates the _id field automatically with an ObjectID if none is given and that you can overwrite the _id when constructing and instance of the model.
What I want: create the _id from other fields in a transparent way. I want to omit the _id field when creating an instance of the model and then have a function called which fills it. This function should be declared on a Schema level and whoever uses the model does not know that _id was filled by the function instead of Mongoose.
Is there a hook or a parameter of the Schema constructor I missed?
Mongoose 3.0.x
Let's make this more concrete. Imagine a BlogPost and I want to create nice URLs by slugging the title. In order to map the slug to a Mongo Object I hash the slug and turn it into a ObjectID to leverage it's benefits. Now what I'm looking for is a transparent method which allows me to create an instance of BlogPost by only passing in title and have the slug and _id property automatically generated.
use a setter on title which slugifies and idifies for you: https://gist.github.com/3658511
If you want to make sure your code is only executed once the object is created, check for this.isNew inside the setter.
Is this what you are looking for?
You could define a function to create the _id before the model is saved, as in:
http://mongoosejs.com/docs/middleware.html
If this middleware is called after Mongoose creates the _id by default (my guess is it's not), you could tell Mongoose to not create an _id, with the _id option.
http://mongoosejs.com/docs/guide.html#options

Resources