results matching ""

    No results matching ""

     1.3.Getting Started

    Learn how to get started with X-server in the browser.

    ¶ 1.3.1. 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:

    <script src="https://TML.ink/X.tml"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.1.1/socket.io.js"></script>
    <script type="text/JavaScript">
    tim = TML('wss://x.TML.ink');
    </script>
    

    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:

    tim = TML('wss://x.TML.ink');
    

    ¶ 1.3.2. Using X-Server in Pure HTML

    The following tutorial uses the Pure HTML to insert data and perform query operations for X-Server.

     {
       nickname:"tim",
       role:"administrator"
    
     }
    

    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.

    ¶ 1.3.3. 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:

    tim.X("collection").New( {
      item: "journal",
      qty: 25,
      status: "A",
      size: { h: 14,
              w: 21,
              uom: "cm" },
      tags: [ "blank", "red" ]
      });
    

    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.

    ¶ 1.3.4. Query Documents

    § 1.3.4.1. 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:

    tim.X("collection").Get()
    

    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":

    tim.X("collection").Get( { status: "D" } )
    

    § 1.3.4.2. Match an Embedded Document

    Equality matches on the whole embedded document require an exact match of the specifieddocument, 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" }:

    tim.X("collection").Get( {size: { h: 14, w: 21, uom: "cm" } } )
    

    § 1.3.4.3. 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":

    tim.X("collection").Get( { "size.uom": "in" } )
    

    § 1.3.4.4. 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:

    tim.X("collection").Get( { tags: "red" } )
    

    § 1.3.4.5. 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:

    tim.X("collection").Get( { tags: ["red", "blank"] } )
    

    For more information and query examples, see Query Documents in the CRUD section.

    To update or delete documents, see Update Documents and Delete Documents.

    ¶ 1.3.5. 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.

    Read Like

    Question & Feedback