How to customize link properties when creating ArangoSearchView in ArangoJS - node.js

I try to create an ArangoSearchView in arangojs, but I don't know how to set up view properties.
Here is my code:
const link = {
includeAllFields: true,
fields: { val: { analyzers: ["text_en"] } },
storeValues: "val"
};
const view = _db.view(`${_viewName}`);
await view.create({ links: {mergeDB : link } });
However, I got this result:

As the error says the issue it's with the storeValue field
According the docs the value should be either none (default) or id
storeValues (optional; type: string; default: "none")
This property controls how the view should keep track of the attribute values. Valid values are:
none: Do not store value meta data in the View.
id: Store information about value presence to allow use of the EXISTS() function.
Not to be confused with storedValues, which stores attribute values in the View index.
Note that there is other parameter called storedValues but it's a top level field (same level as links)

Related

How to fill a reference field automatically in Wix (Velo), with or without code?

I am using a reference field, which contains users nickname, to make a connection between my main collection and 'public data' collection created as default by Wix. I created this reference field to populate a repeater from the two 'main' and 'public data' collections. Is it possible to automatically fill a reference field without using code? If not, then how can use 'beforeInsert' hook to fill the 'the reference' field using code.
I tried to do so in the backend by this code, but it doesn't work.
import { currentMember } from 'wix-members-backend';
export function Collection1_beforeInsert(item, context) {
currentMember.getMember()
.then((member) => {
const id = member._id;
const fullName = `${member.contactDetails.firstName} ${member.contactDetails.lastName}`;
const nickname = member.profile.nickname
console.log(nickname)
item.referenceField= "nickname"
// return member;
})
.catch((error) => {
console.error(error);
});
return item;
}
First off, I'm assuming you're using a regular reference field and not a multi reference field.
Second, it's important to understand how reference fields work before continuing. The reference field holds the ID of the item it is referencing. So when you say the reference field contains a user's nickname, that can't be true. It can contain the ID of the item in PrivateMembersData collection with the nickname you want.
Third, as just mentioned, the nickname field does not exist in the PublicData collection. It is part of the PrivateMembersData collection.
So, if you want to connect your collection to another with the nickname field, you need to set your reference field to reference the PrivateMembersData collection and then store the proper ID in that field.
(Side point: In your code you are putting the same string, "nickname", in every reference field value. You probably meant to use nickname without the quotes. You're also not using promises correctly.)
You can try this code. It should get you closer to what you're looking for.
import { currentMember } from 'wix-members-backend';
export async function Collection1_beforeInsert(item, context) {
const member = await currentMember.getMember();
item.referenceField = member._id;
return item;
}

Given an ElementHandle, how to find the HTML ID associated with it

In Playwright, given a valid ElementHandle object, how do I find the associated HTML ID that is associated with that element?
You could retrieve it with page.evaluate like this:
const elemHandle = await page.$('h1')
const idAttr = await page.evaluate(el => el.id, elemHandle)
console.log(idAttr)
Of course, it is not guaranteed that any element will have an id.
(Note: I am not aware of if the following approach is possible in Playwright as well but it works in puppeteer for sure.)
If you are not restricted to id attributes you can retrieve the unique selectors of an element within the page like:
console.log(elemHandle._remoteObject)
{
type: 'object',
subtype: 'node',
className: 'HTMLHeadingElement',
description: 'h1.fs-headline1.ow-break-word.mb8.flex--item.fl1',
objectId: '5611379091209172520.3.2'
}
Where the value of description is a valid selector.

What is a Mongoose model property that contains 'ref' but does not specify type?

Very new to Mongoose -- I'm working on an existing project and have been given the task of changing some model properties. I understand that if a model contains a property of this type
postedBy: {
type: mongoose.Schema.Types.ObjectId,
ref: 'User'
}
this property references another model/schema, and to get access to that linked model/schema one needs to populate it to gain access to this property.
But in the code I'm reviewing (which I didn't write) there are many properties of this type
contentTypes: [{ ref: 'ContentType' }],
source: { ref: 'Source',required: true },
where another schema is referenced, but there is no type. Is this the same sort of relationship, and the id is implied? Is this a subdocument?
As an additional question: if in a model I wanted to refer to a property of a linked model (or schema), would I need to populate first? That is, if it's a subdocument, I can just use dot notation, but if it is a "linked" document, I'm not sure.
The answer was that the model schemas do not stand on their own, but are passed to a model "factory", which gives them the property types they need.
Thus from that factory the following snippet (below). I looked into the documentation for mongoose-autopopulateand I don't see what autopopulate=truemeans.
new: function(name, properties, statics, methods, schemaMods) {
// Add default definition to properties with references and load reference schemas
Object.keys(properties).forEach(function(key) {
var modifiedProperty = (property) => {
if (property.ref) {
property.autopopulate = true;
property.type = mongoose.Schema.Types.ObjectId;
}
return property;
};
if (Array.isArray(properties[key]) && properties[key].length === 1) {
properties[key][0] = modifiedProperty(properties[key][0]);
} else {
properties[key] = modifiedProperty(properties[key]);
}
});

How to autogenerate id if there is no id in document with elasticjs v5.0

I am trying to add documents, according to elastic search documents, we can add document, even if we dont provide id... See Here
I am trying to add a document even if it doesnt have any ID. in elastic search, how can i do that?
My current code looks like this
var params = _.defaults({}, {
index: index,
type: type, //'customer'
id: data.id || null,
body: data
})
debug(params)
return this.client.create(params);
The above code gives this error
{
"error": "Unable to build a path with those params. Supply at least index, type, id"
}
Any hint would help, thanks
With the create call you MUST provide an id.
If you are not sure if an ID will be present in your data , then you can use the client.index() function instead. using that function, ES will auto-generate an ID if none is provided.

How to perform SubmitFields onto a custom record in SuiteScript 2.0?

To perform SubmitFields onto standard Netsuite Records (i.e. Purchase Orders) it is something like this:
var poId = context.key;
var id = record.submitFields({
type: record.Type.PURCHASE_ORDER,
id: poId,
values: {
custbody_someField: someValue
},
options: {
enableSourcing: false,
ignoreMandatoryFields : true
}
});
What is the type field for Custom Records? I tried the ID of the Custom Record, but it doesn't work:
e.g.
type: record.Type.customrecord_my_record_id
I don't know what the 'official' answer is. The fake enum types don't have any custom record references that I was able to find. Setting the type to the string that is the id of the custom record works for me. (No record.Type. prefix though)
... type: "customrecord_my_record_id", ...
That is true that the references are only for standard record types. You can alternatively get all enums into a variable and log it using
var recordTypesEnums = Object.keys(record.Type);
//you may log recordTypesEnums array

Resources