From Onix OS Wiki
Jump to: navigation, search

If you're using an internal database. Or if you have an indexed database, search () can make your work easier to search and search for indexed data. "Search()" is used to search for large data. A special algorithm in which you can get the correct result in the shortest path.


def resultdef = (search(modeldef, [.....strings] or string))

To search, simply submit the model and string to the database. If you send more than one string as an array, it will search the database directory and bring you the shortest path results.


def indexdb = (database("internal","./indexdb"))
def page = (model(indexdb, "pages", {}))
def i = 0;
  create(page, {"page_"+i:"Example Page ("+i+")"})
  def i = (i+1);
def results = (search(page, ["page_8","page_5", "Example Page 4"]))
...page_8, page_5 or "Example Page 4" search results

For example, we connected to the internal indexed database and created 100 pages, and asked him to bring in the pages containing "page_8","page_5", "Example Page 4".

Some databases do not support the search feature. You may need to develop functions for them yourself. Or you can support this language to connect to more databases.