diff --git a/Documentation/Reference/Querying/uQuery/index.md b/Documentation/Reference/Querying/uQuery/index.md index fdc602fa18e..667085ca495 100644 --- a/Documentation/Reference/Querying/uQuery/index.md +++ b/Documentation/Reference/Querying/uQuery/index.md @@ -1,6 +1,6 @@ # uQuery -uQuery is an API giving read and write access the content, media and member data, as well as extending the relations built in API. uQuery originated from uComponents and was added into Umbraco from v4.8, and can be accessed by referencing the umbraco namespace: +uQuery is an API giving read and write access the content, media and member data, as well as extending the relations API. uQuery originated from uComponents and was added into Umbraco from v4.8, and can be accessed by referencing the umbraco namespace: `using umbraco;` @@ -15,11 +15,50 @@ uQuery has a number of static methods to get collections of Nodes and Documents, ### Items #### GetRootNode +Returns the top level node in the content tree, this node always has an id of -1, so this method is simply a wrapper method. +eg. + +`Node node = uQuery.GetRootNode();` + #### GetCurrentNode +Returns the current content node (unlike Node.GetCurrent() this method will also work in the back office, hence can be used by custom datatypes). There are circumstances where GetCurrentNode() will a return null, for example in the back office on a content item that has never been published (hence it's not in the xml cache). + +eg. + +`Node node = uQuery.GetCurrentNode();` + #### GetCurrentDocument +Returns the current Document - this will also work in the back office and should always return a Document object. + +eg. + +`Document document = uQuery.GetCurrentDocument();` + + #### GetNode +For a given id, returns a Node obj or a null if not found. There are two overloaded methods: GetNode(int) and GetNode(string). + +eg. + +`Node node = uQuery.GetNode(123);` + +or + +`Node node = uQuery.GetNode("123");` + + #### GetDocument +For a given id, returns a Document obj or a null if not found. There are two overloaded methods: GetDocument(int) and GetDocument(string). + +eg. + +`Document document = uQuery.GetDocument(123);` + +or + +`Document document = uQuery.GetDocument("123");` + ---- ### Collections