Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 40 additions & 1 deletion Documentation/Reference/Querying/uQuery/index.md
Original file line number Diff line number Diff line change
@@ -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;`

Expand All @@ -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
Expand Down