gettingstarted
Learn how to get started with X-server in the browser.
Start and Connect to X-server
Prerequisites Ensure that internet is connected before attempting to start.
Create a new HTML file and include those codes:
To explicitly specify the hostname and/or port,
You can specify a connection string. For example, to connect to "wss://x.TML.ink" instance running on a remote host machine:
Using X-Server in Pure HTML
The following tutorial uses the Pure HTML to insert data and perform query operations for X-Server.
The advantages of using documents are: Documents (i.e. objects) correspond to native data types in many programming languages. Embedded documents and arrays reduce need for expensive joins. Dynamic schema supports fluent polymorphism.
Insert Documents
tim.X("collection").New() can insert a new single documents into a collection. Pass a json of document to the method.
The following example inserts new document into the "collection" collection:
New() returns a document that includes the newly inserted documents _id field values. See the reference for an example. For more information and examples, see Insert Documents in the CRUD section.
Query Documents
Select All Documents
To select all documents in the collection, pass an empty document as the query filter document to the tim.X("collection").Get() method:
To query for documents that match specific equality conditions, pass the Get() method a query filter document with the : of the desired documents. The following example selects from the inventory collection all documents where the status equals "D":
Match an Embedded Document
Equality matches on the whole embedded document require an exact match of the specified document, including the field order. For example, the following query selects all documents where the field size equals the document { h: 14, w: 21, uom: "cm" }:
Match a Field in an Embedded Document
The following example selects all documents where the field uom nested in the size field equals the string value "in":
Match an Element in an Array
The following example queries for all documents where tags is an array that contains the string "red" as one of its elements:
Match an Array Exactly
The following example queries for all documents where the field tags value is an array with exactly two elements, "red" and "blank", in the specified order:
For more information and query examples, see Query Documents in the CRUD section.
To update or delete documents, see Update Documents and Delete Documents.
Next Steps
Once you complete the Getting Started Guide, you may find the following course and topics useful.
To learn more about the X-Server fundamentals, see examples chapter.
Last updated