node opcua - Need example on how a client can get all the variables for a given UAObject node ID - opc-ua

When I want to implement a Node.js client program and find all the variables under a given UAObject Node ID, how to do that? Is there an OPC UA library written in Node.js to navigate to child nodes or get all variables under a parent UAObject nodeId?

This sample will demonstrate what you asked:
const { OPCUAClient, NodeClass } = require("node-opcua");
const nodeId = "ns=0;i=2253"; // RootFolder.Objects.Server
const endpointUri = "opc.tcp://localhost:48010";
(async () => {
const client = OPCUAClient.create({ endpoint_must_exist: false});
client.on("backoff", () => console.log("Backoff: trying to connect to ", endpointUri));
await client.withSessionAsync(endpointUri, async (session) => {
let browseResult = await session.browse({
nodeId,
nodeClassMask: NodeClass.Variable, // we only want sub node that are Variables
resultMask: 63 // extract all information possible
});
console.log("BrowseResult = ", browseResult.toString());
});
})();
It will produce this output
BrowseResult = { /*BrowseResult*/
statusCode /* StatusCode */: Good (0x00000)
continuationPoint /* ByteString */: null
references /* ReferenceDescript[] */: [
{ /*0*/
referenceTypeId /* NodeId */: ns=0;i=46
isForward /* UABoolean */: true
nodeId /* ExpandedNodeId */: ns=0;i=2254
browseName /* QualifiedName */: ServerArray
displayName /* LocalizedText */: locale=en text=ServerArray
nodeClass /* NodeClass */: 2 ( 2)
typeDefinition /* ExpandedNodeId */: ns=0;i=68
},
{ /*1*/
referenceTypeId /* NodeId */: ns=0;i=46
isForward /* UABoolean */: true
nodeId /* ExpandedNodeId */: ns=0;i=2255
browseName /* QualifiedName */: NamespaceArray
displayName /* LocalizedText */: locale=en text=NamespaceArray
nodeClass /* NodeClass */: 2 ( 2)
typeDefinition /* ExpandedNodeId */: ns=0;i=68
},
{ /*2*/
referenceTypeId /* NodeId */: ns=0;i=47
isForward /* UABoolean */: true
nodeId /* ExpandedNodeId */: ns=0;i=2256
browseName /* QualifiedName */: ServerStatus
displayName /* LocalizedText */: locale= text=ServerStatus
nodeClass /* NodeClass */: 2 ( 2)
typeDefinition /* ExpandedNodeId */: ns=0;i=2138
},
{ /*3*/
referenceTypeId /* NodeId */: ns=0;i=46
isForward /* UABoolean */: true
nodeId /* ExpandedNodeId */: ns=0;i=2267
browseName /* QualifiedName */: ServiceLevel
displayName /* LocalizedText */: locale=en text=ServiceLevel
nodeClass /* NodeClass */: 2 ( 2)
typeDefinition /* ExpandedNodeId */: ns=0;i=68
},
{ /*4*/
referenceTypeId /* NodeId */: ns=0;i=46
isForward /* UABoolean */: true
nodeId /* ExpandedNodeId */: ns=0;i=2994
browseName /* QualifiedName */: Auditing
displayName /* LocalizedText */: locale=en text=Auditing
nodeClass /* NodeClass */: 2 ( 2)
typeDefinition /* ExpandedNodeId */: ns=0;i=68
},
{ /*5*/
referenceTypeId /* NodeId */: ns=0;i=46
isForward /* UABoolean */: true
nodeId /* ExpandedNodeId */: ns=0;i=12885
browseName /* QualifiedName */: EstimatedReturnTime
displayName /* LocalizedText */: locale=en text=EstimatedReturnTime
nodeClass /* NodeClass */: 2 ( 2)
typeDefinition /* ExpandedNodeId */: ns=0;i=68
}
]
};

Related

In scala 2.13.6+ library, what are the purposes of automatically generated functions with `$extension` suffix?

When I read the decompiled bytecode of scala, I found a lot of functions under the class scala.StringOps:
#scala.inline
final def view$extension($this : scala.collection.StringOps) : scala.collection.StringView = { /* compiled code */ }
#scala.inline
final def size$extension($this : scala.collection.StringOps) : scala.Int = { /* compiled code */ }
#scala.inline
final def knownSize$extension($this : scala.collection.StringOps) : scala.Int = { /* compiled code */ }
#scala.inline
final def apply$extension($this : scala.collection.StringOps)(i : scala.Int) : scala.Char = { /* compiled code */ }
final def sizeCompare$extension($this : scala.collection.StringOps)(otherSize : scala.Int) : scala.Int = { /* compiled code */ }
final def lengthCompare$extension($this : scala.collection.StringOps)(len : scala.Int) : scala.Int = { /* compiled code */ }
final def sizeIs$extension($this : scala.collection.StringOps) : scala.Int = { /* compiled code */ }
final def lengthIs$extension($this : scala.collection.StringOps) : scala.Int = { /* compiled code */ }
final def map$extension[B]($this : scala.collection.StringOps)(f : scala.Function1[scala.Char, B]) : scala.collection.immutable.IndexedSeq[B] = { /* compiled code */ }
final def map$extension($this : scala.collection.StringOps)(f : scala.Function1[scala.Char, scala.Char]) : _root_.scala.Predef.String = { /* compiled code */ }
final def flatMap$extension[B]($this : scala.collection.StringOps)(f : scala.Function1[scala.Char, scala.collection.IterableOnce[B]]) : scala.collection.immutable.IndexedSeq[B] = { /* compiled code */ }
final def flatMap$extension($this : scala.collection.StringOps)(f : scala.Function1[scala.Char, _root_.scala.Predef.String]) : _root_.scala.Predef.String = { /* compiled code */ }
final def collect$extension($this : scala.collection.StringOps)(pf : scala.PartialFunction[scala.Char, scala.Char]) : _root_.scala.Predef.String = { /* compiled code */ }
final def collect$extension[B]($this : scala.collection.StringOps)(pf : scala.PartialFunction[scala.Char, B]) : scala.collection.immutable.IndexedSeq[B] = { /* compiled code */ }
final def concat$extension[B >: scala.Char]($this : scala.collection.StringOps)(suffix : scala.collection.IterableOnce[B]) : scala.collection.immutable.IndexedSeq[B] = { /* compiled code */ }
final def concat$extension($this : scala.collection.StringOps)(suffix : scala.collection.IterableOnce[scala.Char]) : _root_.scala.Predef.String = { /* compiled code */ }
#scala.inline
final def concat$extension($this : scala.collection.StringOps)(suffix : _root_.scala.Predef.String) : _root_.scala.Predef.String = { /* compiled code */ }
#scala.inline
final def `++$extension`[B >: scala.Char]($this : scala.collection.StringOps)(suffix : scala.collection.Iterable[B]) : scala.collection.immutable.IndexedSeq[B] = { /* compiled code */ }
#scala.inline
final def `++$extension`($this : scala.collection.StringOps)(suffix : scala.collection.IterableOnce[scala.Char]) : _root_.scala.Predef.String = { /* compiled code */ }
final def `++$extension`($this : scala.collection.StringOps)(xs : _root_.scala.Predef.String) : _root_.scala.Predef.String = { /* compiled code */ }
final def padTo$extension[B >: scala.Char]($this : scala.collection.StringOps)(len : scala.Int, elem : B) : scala.collection.immutable.IndexedSeq[B] = { /* compiled code */ }
final def padTo$extension($this : scala.collection.StringOps)(len : scala.Int, elem : scala.Char) : _root_.scala.Predef.String = { /* compiled code */ }
final def prepended$extension[B >: scala.Char]($this : scala.collection.StringOps)(elem : B) : scala.collection.immutable.IndexedSeq[B] = { /* compiled code */ }
#scala.inline
final def `+:$extension`[B >: scala.Char]($this : scala.collection.StringOps)(elem : B) : scala.collection.immutable.IndexedSeq[B] = { /* compiled code */ }
final def prepended$extension($this : scala.collection.StringOps)(c : scala.Char) : _root_.scala.Predef.String = { /* compiled code */ }
#scala.inline
final def `+:$extension`($this : scala.collection.StringOps)(c : scala.Char) : _root_.scala.Predef.String = { /* compiled code */ }
final def prependedAll$extension[B >: scala.Char]($this : scala.collection.StringOps)(prefix : scala.collection.IterableOnce[B]) : scala.collection.immutable.IndexedSeq[B] = { /* compiled code */ }
#scala.inline
final def `++:$extension`[B >: scala.Char]($this : scala.collection.StringOps)(prefix : scala.collection.IterableOnce[B]) : scala.collection.immutable.IndexedSeq[B] = { /* compiled code */ }
final def prependedAll$extension($this : scala.collection.StringOps)(prefix : _root_.scala.Predef.String) : _root_.scala.Predef.String = { /* compiled code */ }
#scala.inline
final def `++:$extension`($this : scala.collection.StringOps)(prefix : _root_.scala.Predef.String) : _root_.scala.Predef.String = { /* compiled code */ }
final def appended$extension[B >: scala.Char]($this : scala.collection.StringOps)(elem : B) : scala.collection.immutable.IndexedSeq[B] = { /* compiled code */ }
#scala.inline
final def `:+$extension`[B >: scala.Char]($this : scala.collection.StringOps)(elem : B) : scala.collection.immutable.IndexedSeq[B] = { /* compiled code */ }
final def appended$extension($this : scala.collection.StringOps)(c : scala.Char) : _root_.scala.Predef.String = { /* compiled code */ }
#scala.inline
final def `:+$extension`($this : scala.collection.StringOps)(c : scala.Char) : _root_.scala.Predef.String = { /* compiled code */ }
#scala.inline
final def appendedAll$extension[B >: scala.Char]($this : scala.collection.StringOps)(suffix : scala.collection.IterableOnce[B]) : scala.collection.immutable.IndexedSeq[B] = { /* compiled code */ }
#scala.inline
final def `:++$extension`[B >: scala.Char]($this : scala.collection.StringOps)(suffix : scala.collection.IterableOnce[B]) : scala.collection.immutable.IndexedSeq[B] = { /* compiled code */ }
#scala.inline
final def appendedAll$extension($this : scala.collection.StringOps)(suffix : _root_.scala.Predef.String) : _root_.scala.Predef.String = { /* compiled code */ }
#scala.inline
final def `:++$extension`($this : scala.collection.StringOps)(suffix : _root_.scala.Predef.String) : _root_.scala.Predef.String = { /* compiled code */ }
final def patch$extension[B >: scala.Char]($this : scala.collection.StringOps)(from : scala.Int, other : scala.collection.IterableOnce[B], replaced : scala.Int) : scala.collection.immutable.IndexedSeq[B] = { /* compiled code */ }
final def patch$extension($this : scala.collection.StringOps)(from : scala.Int, other : scala.collection.IterableOnce[scala.Char], replaced : scala.Int) : _root_.scala.Predef.String = { /* compiled code */ }
final def patch$extension($this : scala.collection.StringOps)(from : scala.Int, other : _root_.scala.Predef.String, replaced : scala.Int) : _root_.scala.Predef.String = { /* compiled code */ }
final def updated$extension($this : scala.collection.StringOps)(index : scala.Int, elem : scala.Char) : _root_.scala.Predef.String = { /* compiled code */ }
final def contains$extension($this : scala.collection.StringOps)(elem : scala.Char) : scala.Boolean = { /* compiled code */ }
final def mkString$extension($this : scala.collection.StringOps)(start : _root_.scala.Predef.String, sep : _root_.scala.Predef.String, end : _root_.scala.Predef.String) : _root_.scala.Predef.String = { /* compiled code */ }
#scala.inline
final def mkString$extension($this : scala.collection.StringOps)(sep : _root_.scala.Predef.String) : _root_.scala.Predef.String = { /* compiled code */ }
#scala.inline
final def mkString$extension($this : scala.collection.StringOps) : _root_.scala.Predef.String = { /* compiled code */ }
#scala.inline
final def addString$extension($this : scala.collection.StringOps)(b : scala.collection.mutable.StringBuilder) : scala.collection.mutable.StringBuilder = { /* compiled code */ }
#scala.inline
final def addString$extension($this : scala.collection.StringOps)(b : scala.collection.mutable.StringBuilder, sep : _root_.scala.Predef.String) : scala.collection.mutable.StringBuilder = { /* compiled code */ }
final def addString$extension($this : scala.collection.StringOps)(b : scala.collection.mutable.StringBuilder, start : _root_.scala.Predef.String, sep : _root_.scala.Predef.String, end : _root_.scala.Predef.String) : scala.collection.mutable.StringBuilder = { /* compiled code */ }
final def slice$extension($this : scala.collection.StringOps)(from : scala.Int, until : scala.Int) : _root_.scala.Predef.String = { /* compiled code */ }
final def `*$extension`($this : scala.collection.StringOps)(n : scala.Int) : _root_.scala.Predef.String = { /* compiled code */ }
#scala.inline
final def isLineBreak$extension($this : scala.collection.StringOps)(c : scala.Char) : scala.Boolean = { /* compiled code */ }
#scala.inline
final def isLineBreak2$extension($this : scala.collection.StringOps)(c0 : scala.Char, c : scala.Char) : scala.Boolean = { /* compiled code */ }
final def stripLineEnd$extension($this : scala.collection.StringOps) : _root_.scala.Predef.String = { /* compiled code */ }
final def linesWithSeparators$extension($this : scala.collection.StringOps) : scala.collection.Iterator[_root_.scala.Predef.String] = { /* compiled code */ }
final def linesIterator$extension($this : scala.collection.StringOps) : scala.collection.Iterator[_root_.scala.Predef.String] = { /* compiled code */ }
final def linesSeparated$extension($this : scala.collection.StringOps)(stripped : scala.Boolean) : scala.collection.Iterator[_root_.scala.Predef.String] = { /* compiled code */ }
#scala.deprecated(message = "Use `linesIterator`, because JDK 11 adds a `lines` method on String", since = "2.13.0")
final def lines$extension($this : scala.collection.StringOps) : scala.collection.Iterator[_root_.scala.Predef.String] = { /* compiled code */ }
final def capitalize$extension($this : scala.collection.StringOps) : _root_.scala.Predef.String = { /* compiled code */ }
final def stripPrefix$extension($this : scala.collection.StringOps)(prefix : _root_.scala.Predef.String) : java.lang.String = { /* compiled code */ }
final def stripSuffix$extension($this : scala.collection.StringOps)(suffix : _root_.scala.Predef.String) : java.lang.String = { /* compiled code */ }
#scala.deprecated(message = "Use `s.replace` as an exact replacement", since = "2.13.2")
final def replaceAllLiterally$extension($this : scala.collection.StringOps)(literal : _root_.scala.Predef.String, replacement : _root_.scala.Predef.String) : _root_.scala.Predef.String = { /* compiled code */ }
final def stripMargin$extension($this : scala.collection.StringOps)(marginChar : scala.Char) : _root_.scala.Predef.String = { /* compiled code */ }
final def stripMargin$extension($this : scala.collection.StringOps) : _root_.scala.Predef.String = { /* compiled code */ }
final def escape$extension($this : scala.collection.StringOps)(ch : scala.Char) : _root_.scala.Predef.String = { /* compiled code */ }
final def split$extension($this : scala.collection.StringOps)(separator : scala.Char) : scala.Array[_root_.scala.Predef.String] = { /* compiled code */ }
#scala.throws[java.util.regex.PatternSyntaxException](classOf[java.util.regex.PatternSyntaxException])
final def split$extension($this : scala.collection.StringOps)(separators : scala.Array[scala.Char]) : scala.Array[_root_.scala.Predef.String] = { /* compiled code */ }
final def r$extension($this : scala.collection.StringOps) : scala.util.matching.Regex = { /* compiled code */ }
final def r$extension($this : scala.collection.StringOps)(groupNames : _root_.scala.Predef.String*) : scala.util.matching.Regex = { /* compiled code */ }
final def toBoolean$extension($this : scala.collection.StringOps) : scala.Boolean = { /* compiled code */ }
final def toBooleanOption$extension($this : scala.collection.StringOps) : scala.Option[scala.Boolean] = { /* compiled code */ }
final def toByte$extension($this : scala.collection.StringOps) : scala.Byte = { /* compiled code */ }
final def toByteOption$extension($this : scala.collection.StringOps) : scala.Option[scala.Byte] = { /* compiled code */ }
final def toShort$extension($this : scala.collection.StringOps) : scala.Short = { /* compiled code */ }
final def toShortOption$extension($this : scala.collection.StringOps) : scala.Option[scala.Short] = { /* compiled code */ }
final def toInt$extension($this : scala.collection.StringOps) : scala.Int = { /* compiled code */ }
final def toIntOption$extension($this : scala.collection.StringOps) : scala.Option[scala.Int] = { /* compiled code */ }
final def toLong$extension($this : scala.collection.StringOps) : scala.Long = { /* compiled code */ }
final def toLongOption$extension($this : scala.collection.StringOps) : scala.Option[scala.Long] = { /* compiled code */ }
final def toFloat$extension($this : scala.collection.StringOps) : scala.Float = { /* compiled code */ }
final def toFloatOption$extension($this : scala.collection.StringOps) : scala.Option[scala.Float] = { /* compiled code */ }
final def toDouble$extension($this : scala.collection.StringOps) : scala.Double = { /* compiled code */ }
final def toDoubleOption$extension($this : scala.collection.StringOps) : scala.Option[scala.Double] = { /* compiled code */ }
final def toBooleanImpl$extension($this : scala.collection.StringOps)(s : _root_.scala.Predef.String) : scala.Boolean = { /* compiled code */ }
final def toArray$extension[B >: scala.Char]($this : scala.collection.StringOps)(implicit tag : scala.reflect.ClassTag[B]) : scala.Array[B] = { /* compiled code */ }
final def unwrapArg$extension($this : scala.collection.StringOps)(arg : scala.Any) : scala.AnyRef = { /* compiled code */ }
final def format$extension($this : scala.collection.StringOps)(args : scala.Any*) : _root_.scala.Predef.String = { /* compiled code */ }
final def formatLocal$extension($this : scala.collection.StringOps)(l : java.util.Locale, args : scala.Any*) : _root_.scala.Predef.String = { /* compiled code */ }
final def compare$extension($this : scala.collection.StringOps)(that : _root_.scala.Predef.String) : scala.Int = { /* compiled code */ }
final def `<$extension`($this : scala.collection.StringOps)(that : _root_.scala.Predef.String) : scala.Boolean = { /* compiled code */ }
final def `>$extension`($this : scala.collection.StringOps)(that : _root_.scala.Predef.String) : scala.Boolean = { /* compiled code */ }
final def `<=$extension`($this : scala.collection.StringOps)(that : _root_.scala.Predef.String) : scala.Boolean = { /* compiled code */ }
final def `>=$extension`($this : scala.collection.StringOps)(that : _root_.scala.Predef.String) : scala.Boolean = { /* compiled code */ }
final def count$extension($this : scala.collection.StringOps)(p : scala.Function1[scala.Char, scala.Boolean]) : scala.Int = { /* compiled code */ }
final def foreach$extension[U]($this : scala.collection.StringOps)(f : scala.Function1[scala.Char, U]) : scala.Unit = { /* compiled code */ }
final def forall$extension($this : scala.collection.StringOps)(p : scala.Function1[scala.Char, scala.Boolean]) : scala.Boolean = { /* compiled code */ }
final def foldLeft$extension[B]($this : scala.collection.StringOps)(z : B)(op : scala.Function2[B, scala.Char, B]) : B = { /* compiled code */ }
final def foldRight$extension[B]($this : scala.collection.StringOps)(z : B)(op : scala.Function2[scala.Char, B, B]) : B = { /* compiled code */ }
#scala.inline
final def fold$extension[A1 >: scala.Char]($this : scala.collection.StringOps)(z : A1)(op : scala.Function2[A1, A1, A1]) : A1 = { /* compiled code */ }
final def head$extension($this : scala.collection.StringOps) : scala.Char = { /* compiled code */ }
final def headOption$extension($this : scala.collection.StringOps) : scala.Option[scala.Char] = { /* compiled code */ }
final def last$extension($this : scala.collection.StringOps) : scala.Char = { /* compiled code */ }
final def lastOption$extension($this : scala.collection.StringOps) : scala.Option[scala.Char] = { /* compiled code */ }
final def indices$extension($this : scala.collection.StringOps) : scala.Range = { /* compiled code */ }
final def iterator$extension($this : scala.collection.StringOps) : scala.collection.Iterator[scala.Char] = { /* compiled code */ }
#scala.inline
final def stepper$extension($this : scala.collection.StringOps) : scala.collection.IntStepper with scala.collection.Stepper.EfficientSplit = { /* compiled code */ }
#scala.inline
final def charStepper$extension($this : scala.collection.StringOps) : scala.collection.IntStepper with scala.collection.Stepper.EfficientSplit = { /* compiled code */ }
#scala.inline
final def codePointStepper$extension($this : scala.collection.StringOps) : scala.collection.IntStepper with scala.collection.Stepper.EfficientSplit = { /* compiled code */ }
#scala.inline
final def nonEmpty$extension($this : scala.collection.StringOps) : scala.Boolean = { /* compiled code */ }
final def reverse$extension($this : scala.collection.StringOps) : _root_.scala.Predef.String = { /* compiled code */ }
final def reverseIterator$extension($this : scala.collection.StringOps) : scala.collection.Iterator[scala.Char] = { /* compiled code */ }
final def withFilter$extension($this : scala.collection.StringOps)(p : scala.Function1[scala.Char, scala.Boolean]) : scala.collection.StringOps.WithFilter = { /* compiled code */ }
final def tail$extension($this : scala.collection.StringOps) : _root_.scala.Predef.String = { /* compiled code */ }
final def init$extension($this : scala.collection.StringOps) : _root_.scala.Predef.String = { /* compiled code */ }
final def take$extension($this : scala.collection.StringOps)(n : scala.Int) : _root_.scala.Predef.String = { /* compiled code */ }
final def drop$extension($this : scala.collection.StringOps)(n : scala.Int) : _root_.scala.Predef.String = { /* compiled code */ }
final def takeRight$extension($this : scala.collection.StringOps)(n : scala.Int) : _root_.scala.Predef.String = { /* compiled code */ }
final def dropRight$extension($this : scala.collection.StringOps)(n : scala.Int) : _root_.scala.Predef.String = { /* compiled code */ }
final def tails$extension($this : scala.collection.StringOps) : scala.collection.Iterator[_root_.scala.Predef.String] = { /* compiled code */ }
final def inits$extension($this : scala.collection.StringOps) : scala.collection.Iterator[_root_.scala.Predef.String] = { /* compiled code */ }
final def iterateUntilEmpty$extension($this : scala.collection.StringOps)(f : scala.Function1[_root_.scala.Predef.String, _root_.scala.Predef.String]) : scala.collection.Iterator[_root_.scala.Predef.String] = { /* compiled code */ }
final def filter$extension($this : scala.collection.StringOps)(pred : scala.Function1[scala.Char, scala.Boolean]) : _root_.scala.Predef.String = { /* compiled code */ }
#scala.inline
final def filterNot$extension($this : scala.collection.StringOps)(pred : scala.Function1[scala.Char, scala.Boolean]) : _root_.scala.Predef.String = { /* compiled code */ }
#scala.inline
final def copyToArray$extension($this : scala.collection.StringOps)(xs : scala.Array[scala.Char]) : scala.Int = { /* compiled code */ }
#scala.inline
final def copyToArray$extension($this : scala.collection.StringOps)(xs : scala.Array[scala.Char], start : scala.Int) : scala.Int = { /* compiled code */ }
final def copyToArray$extension($this : scala.collection.StringOps)(xs : scala.Array[scala.Char], start : scala.Int, len : scala.Int) : scala.Int = { /* compiled code */ }
final def indexWhere$extension($this : scala.collection.StringOps)(p : scala.Function1[scala.Char, scala.Boolean], from : scala.Int = { /* compiled code */ }) : scala.Int = { /* compiled code */ }
final def lastIndexWhere$extension($this : scala.collection.StringOps)(p : scala.Function1[scala.Char, scala.Boolean], end : scala.Int = { /* compiled code */ }) : scala.Int = { /* compiled code */ }
final def exists$extension($this : scala.collection.StringOps)(p : scala.Function1[scala.Char, scala.Boolean]) : scala.Boolean = { /* compiled code */ }
final def find$extension($this : scala.collection.StringOps)(p : scala.Function1[scala.Char, scala.Boolean]) : scala.Option[scala.Char] = { /* compiled code */ }
final def dropWhile$extension($this : scala.collection.StringOps)(p : scala.Function1[scala.Char, scala.Boolean]) : _root_.scala.Predef.String = { /* compiled code */ }
final def takeWhile$extension($this : scala.collection.StringOps)(p : scala.Function1[scala.Char, scala.Boolean]) : _root_.scala.Predef.String = { /* compiled code */ }
final def splitAt$extension($this : scala.collection.StringOps)(n : scala.Int) : scala.Tuple2[_root_.scala.Predef.String, _root_.scala.Predef.String] = { /* compiled code */ }
final def span$extension($this : scala.collection.StringOps)(p : scala.Function1[scala.Char, scala.Boolean]) : scala.Tuple2[_root_.scala.Predef.String, _root_.scala.Predef.String] = { /* compiled code */ }
final def grouped$extension($this : scala.collection.StringOps)(size : scala.Int) : scala.collection.Iterator[_root_.scala.Predef.String] = { /* compiled code */ }
final def partition$extension($this : scala.collection.StringOps)(p : scala.Function1[scala.Char, scala.Boolean]) : scala.Tuple2[_root_.scala.Predef.String, _root_.scala.Predef.String] = { /* compiled code */ }
final def partitionMap$extension($this : scala.collection.StringOps)(f : scala.Function1[scala.Char, scala.Either[scala.Char, scala.Char]]) : scala.Tuple2[_root_.scala.Predef.String, _root_.scala.Predef.String] = { /* compiled code */ }
final def lazyZip$extension[B]($this : scala.collection.StringOps)(that : scala.collection.Iterable[B]) : scala.collection.LazyZip2[scala.Char, B, _root_.scala.Predef.String] = { /* compiled code */ }
final def diff$extension[B >: scala.Char]($this : scala.collection.StringOps)(that : scala.collection.Seq[B]) : _root_.scala.Predef.String = { /* compiled code */ }
final def intersect$extension[B >: scala.Char]($this : scala.collection.StringOps)(that : scala.collection.Seq[B]) : _root_.scala.Predef.String = { /* compiled code */ }
final def distinct$extension($this : scala.collection.StringOps) : _root_.scala.Predef.String = { /* compiled code */ }
final def distinctBy$extension[B]($this : scala.collection.StringOps)(f : scala.Function1[scala.Char, B]) : _root_.scala.Predef.String = { /* compiled code */ }
final def sorted$extension[B >: scala.Char]($this : scala.collection.StringOps)(implicit ord : scala.Ordering[B]) : _root_.scala.Predef.String = { /* compiled code */ }
final def sortWith$extension($this : scala.collection.StringOps)(lt : scala.Function2[scala.Char, scala.Char, scala.Boolean]) : _root_.scala.Predef.String = { /* compiled code */ }
final def sortBy$extension[B]($this : scala.collection.StringOps)(f : scala.Function1[scala.Char, B])(implicit ord : scala.Ordering[B]) : _root_.scala.Predef.String = { /* compiled code */ }
final def groupBy$extension[K]($this : scala.collection.StringOps)(f : scala.Function1[scala.Char, K]) : scala.collection.immutable.Map[K, _root_.scala.Predef.String] = { /* compiled code */ }
final def sliding$extension($this : scala.collection.StringOps)(size : scala.Int, step : scala.Int = { /* compiled code */ }) : scala.collection.Iterator[_root_.scala.Predef.String] = { /* compiled code */ }
final def combinations$extension($this : scala.collection.StringOps)(n : scala.Int) : scala.collection.Iterator[_root_.scala.Predef.String] = { /* compiled code */ }
final def permutations$extension($this : scala.collection.StringOps) : scala.collection.Iterator[_root_.scala.Predef.String] = { /* compiled code */ }
The are clearly generated automatically (as they have no counterpart in source code or javadoc). Yet I cannot find any official explanation to this. So my questions are:
What are their purposes?
How can I generate similar functions automatically for my own project?
Those methods are generated because StringOps is a value class. You can read the value classes SIP to see how they are translated.
Basically new StringOps("foo").view is translated to StringOps.view$extension("foo") to avoid any boxing.

mongoose populated by subdocument ID

Assume the following Schema:
Aschema
ASchema = {
type: { type: ObjectId, ref: BModel }
}
/**
* ADoc = {
* _id: 00a1,
* type: 00b1001
* },
*
*/
BSchema
BSchema = {
children: [{
name: String,
}]
}
/**
* BDoc = {
* _id: 00b1,
* children: [{
* _id: 00b1001,
* name: 'b1'
* }, {
* _id: 00b1002,
* name: 'b2'
* }]
* }
*
*/
When I find by _id: "00a1", I will get the following results
AModel.find({_id: '00a1'}).lean();
/**
* {
* _id: 00a1,
* type: 00b1001
* }
*/
As you can see, my ASchema type ref refs the ObjectId of a subdocument in B document
I want to get this result
/**
* {
* _id: 00a1,
* type: {
* _id: 00b1001,
* name: 'b1'
* }
* }
*/
I know there is populate, but I get null, hope to get everyone's help, thank you!
I posted the same question, but the description is not clear enough.
How to use populate with sub-doc ObjectId

PHP/MongoDB - Doctrine ODM Hydrate in some cases others not

I need some help in Doctrine ODM, in some cases the hydrate do not return the expected values.
I have on project as example and when I query for a collection and all work fine with hydrate, this is the case that works:
ProductsCollection:
<?php
namespace MongodbManager\Documents;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
use Doctrine\Common\Collections\ArrayCollection;
/** #ODM\Document */
class ProductsODM
{
/** #ODM\Id */
public $id;
/** #ODM\Field(type="string") */
public $name;
/** #ODM\Field(type="float") */
public $price;
/** #ODM\Field(type="date") */
public $date;
/** #ODM\EmbedMany(targetDocument=CategoriesODM::class) */
public $categories;
/** #ODM\ReferenceMany(targetDocument=TagsODM::class, storeAs="id") */
public $tags;
/** #ODM\ReferenceOne(targetDocument=TagsODM::class, storeAs="id") */
public $tagsPrimary;
public function __construct()
{
$this->categories = new ArrayCollection();
}
}
TagsCollection
<?php
namespace MongodbManager\Documents;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
/** #ODM\Document */
class TagsODM
{
/** #ODM\Id */
public $id;
/** #ODM\Field(type="string") */
public $name;
}
Query (WORKS!)
$this->dm->createQueryBuilder(ProductsODM::class)->hydrate(true)->getQuery()->execute();
Return (content):
{
"id": "5d9e23b32b251b2fc7438d14",
"name": "Martini 1570644915",
"price": 5.99,
"date": {
"date": "2019-10-09 15:15:15.000000",
"timezone_type": 3,
"timezone": "America/Sao_Paulo"
},
"categories": [
{
"id": "5d9e23b32b251b2fc7438d15",
"name": "bar"
},
{
"id": "5d9e23b32b251b2fc7438d16",
"name": "night"
}
],
"tags": [
{
"id": "5d9dde11982e830950453618",
"name": "COMIDA"
},
{
"id": "5d9dde11982e830950453619",
"name": "BEBIDA"
}
],
"tagsPrimary": {
"id": "5d9dde11982e830950453618",
"name": "COMIDA"
}
}
As you can see the result came with Tags values.
HERE IS THE PROBLEM:in the UsersODM when I query for documents do not include the values of UsersGrousODM in the result, just the id, here is the code:
<?php
namespace MongodbManager\Documents;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
/** #ODM\Document */
class UsersODM
{
/** #ODM\Id */
public $id;
/** #ODM\Field(type="string") */
public $users_login_code;
/** #ODM\Field(type="string") */
public $users_username;
/** #ODM\Field(type="string") */
public $users_password;
/** #ODM\Field(type="string") */
public $users_status;
/** #ODM\Field(type="date") */
public $users_update_date;
/** #ODM\ReferenceOne(targetDocument=UsersGroupODM::class, storeAs="id") **/
public $users_group_id;
}
The UsersGroupODM
<?php
namespace MongodbManager\Documents;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
/** #ODM\Document */
class UsersGroupODM
{
/** #ODM\Id */
public $id;
/** #ODM\Field(type="string") */
public $users_group_name;
/** #ODM\Field(type="string") */
public $users_group_status;
}
The Query:
$this->dm->createQueryBuilder(UsersODM::class)hydrate(true)->getQuery()->execute();
Return:
{
"id": "5d9e2b0991055769a44078c6",
"users_login_code": null,
"users_username": "webmaster",
"users_password": "d68b87ecdf82164583816f1306f4c342ba57ad3e......",
"users_status": "active",
"users_update_date": {
"date": "2019-10-09 15:46:33.000000",
"timezone_type": 3,
"timezone": "America/Sao_Paulo"
},
"users_group_id": {
"id": "5d9e289358063a6594142cbc"
},
"users_info": null
}
the users_group_id do not include the field users_group_name and users_group_status.

What should be the base URL for the images in magento?

After accessing the Rest API (http://192.168.1.180/magento/index.php/rest/V1/products/SKU) to get the product details, the response is something like this:
{
"attribute_code": "image",
"value": "/6/4/64275-152378-large.jpg"
},
{
"attribute_code": "small_image",
"value": "/6/4/64275-152378-large.jpg"
},
{
"attribute_code": "thumbnail",
"value": "/6/4/64275-152378-large.jpg"
}
What should be the base url for the jpg in the attribute_code keys ?
There is no need for modifying the API request.
Just add a prefix: http://magento.com/pub/media/catalog/product/
So the new URL according to my response will be:
Prefix: http://magento.com/pub/media/catalog/product/6/4/64275-152378-large.jpg
/** #return string */
function getMediaBaseUrl() {
/** #var \Magento\Framework\ObjectManagerInterface $om */
$om = \Magento\Framework\App\ObjectManager::getInstance();
/** #var \Magento\Store\Model\StoreManagerInterface $storeManager */
$storeManager = $om->get('Magento\Store\Model\StoreManagerInterface');
/** #var \Magento\Store\Api\Data\StoreInterface|\Magento\Store\Model\Store $currentStore */
$currentStore = $storeManager->getStore();
return $currentStore->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA);
}

How can I fetch just a document without his referenced documents

I have two Documents: Client and PV. Many PV are referenced in one Client. It's unidirectional.
Client
/**
* #MongoDB\Document
*/
class Client
{
/**
* #MongoDB\Id(strategy="auto")
*/
protected $id;
/**
* #MongoDB\String
*/
protected $name;
/**
* #MongoDB\ReferenceMany(targetDocument="PV", simple=true, cascade={"persist", "remove"})
*/
private $PV = array();
public function __construct()
{
$this->PV = new \Doctrine\Common\Collections\ArrayCollection();
}
}
PV
/**
* #MongoDB\Document
*/
class PV
{
/**
* #MongoDB\Id(strategy="auto")
*/
protected $id;
/**
* #MongoDB\String
*/
protected $name;
}
To fetch a Client Document I use:
$client = $this->get('doctrine_mongodb')
->getRepository('HubMainBundle:Client')
->findOneById($id);
And I get:
"53da113176a2955c6d8b4567": {
"id": "53da113176a2955c6d8b4567",
"name": "Test",
"_p_v": [
{
"id": "53da121276a2956c708b4568",
"name": "test pv"
},
{
"id": "53da4e2876a295b7088b4567",
"name": "pv 2"
}
]
}
But I want:
"53da113176a2955c6d8b4567": {
"id": "53da113176a2955c6d8b4567",
"name": "Test",
"_p_v" : [
"53da121276a2956c708b4568",
"53da4e2876a295b7088b4567"
]
}
So how can I fetch just the Parent Document with MongoIds for every PV referenced not the entires referenced PVs ? (In MongoDB when I do db.Client.find({name: 'Test'}) I got the MongoIds not the documents).
Is it related to the Doctrine MongoDB hydrator ?