<?xml version="1.0" encoding="utf-8"?>
<KScriptSetting>
  <Name>tableQuery</Name>
  <Description>Query the table with paged result.</Description>
  <Example><![CDATA[
    <script engine="kscript">
    var table = k.database.getTable("mytablename");
    var obj = {name: "myname", number: 124};
    table.add(obj);
    var obj2 = {name: "myname", number: 125};
    table.add(obj2);

    // query table
    var values = table.query("number>=123").orderBy("number").skip(1).take(10);
    // or the same
    var values = table.query().where("number>=123").OrderByDescending("number").skip(1).take(10);

    /// syntax of searchCondition: fieldname operator value;
    // all available operators: ==,  >=,  >,  <,  <=, contains, startwith

    </script>
    
    <div k-foreach="item values">
    <p k-content="item.name">name value</p>
    <p k-content="item.number">number</p>
    </div> 
	]]></Example>
  <Props>
    <Property>
      <Name>skipcount</Name>
      <Description>the number of items that will be skipped</Description>
      <Type>Int32</Type>
    </Property>
    <Property>
      <Name>Ascending</Name>
      <Description>Is ascending order</Description>
      <Type>boolean</Type>
    </Property>
    <Property>
      <Name>OrderByField</Name>
      <Description>The field name to order by</Description>
      <Type>string</Type>
    </Property>
    <Property>
      <Name>SearchCondition</Name>
      <Description>The search condition text</Description>
      <Type>string</Type>
    </Property>
  </Props>
  <Methods>
    <Method>
      <Name>skip</Name>
      <Description>skip</Description>
      <Example><![CDATA[
        var values = table.query("number>=123").orderBy("number").skip(1).take(10);
	  ]]></Example>
      <Params>
        <Param>
          <Name>skip</Name>
          <Description>skip count</Description>
          <Type>number</Type>
        </Param>
      </Params>
      <ReturnType>TableQuery</ReturnType>
    </Method>
    <Method>
      <Name>Where</Name>
      <Description>The seach condition text</Description>
      <Example><![CDATA[
        var values = table.query().where("number>=123").take(10);
        // same as
        var values = table.query("number>=123").take(10);
		]]></Example>
      <Params>
        <Param>
          <Name>searchCondition</Name>
          <Description>searchCondition</Description>
          <Type>string</Type>
        </Param>
      </Params>
      <ReturnType>TableQuery</ReturnType>
    </Method>
    <Method>
      <Name>OrderBy</Name>
      <Description>the order by field name</Description>
      <Example><![CDATA[
        var values = table.query("number>=123").orderBy("number").take(10);
		]]></Example>
      <Params>
        <Param>
          <Name>fieldname</Name>
          <Description>fieldname</Description>
          <Type>string</Type>
        </Param>
      </Params>
      <ReturnType>TableQuery</ReturnType>
    </Method>
    <Method>
      <Name>OrderByDescending</Name>
      <Description>the field name to order by in Descending order</Description>
      <Example><![CDATA[
        var values = table.query("number>=123").orderByDescending("number").skip(1).take(10);
		]]></Example>
      <Params>
        <Param>
          <Name>fieldname</Name>
          <Description>fieldname</Description>
          <Type>string</Type>
        </Param>
      </Params>
      <ReturnType>TableQuery</ReturnType>
    </Method>
    <Method>
      <Name>take</Name>
      <Description>Number of items to return</Description>
      <Example><![CDATA[
        var values = table.query("number>=123").take(10);
		]]></Example>
      <Params>
        <Param>
          <Name>count</Name>
          <Description>count</Description>
          <Type>number</Type>
        </Param>
      </Params>
      <ReturnType>array</ReturnType>
    </Method>
    <Method>
      <Name>count</Name>
      <Description>count</Description>
      <Example>count</Example>
      <Params />
      <ReturnType>Int32</ReturnType>
    </Method>
  </Methods>
</KScriptSetting>