Introduction Installation Projects Tables Inserts Searches Updates Deletes Production Installation Conclusion

Searches - Flaarum Tutorials

Flaarum provides statements for different searches. This makes searches more comfortable than using a function call.

Sample Code

cl := flaarum.NewClient("127.0.0.1", "not-yet-ready", "first_proj")
rows, err := cl.Search(`
table: user_roles expand
limit: 100
where:
	user = 32
`)
if err != nil {
	panic(err)
}

roles := make([]string, 0)
for _, row := range *rows {
	roles = append(roles, row["roleid.role"])
}
		

Sample Search Statements

  1. table: users
    fields: name email
    limit: 10
    start_index: 50
    order_by: reg_dt asc
    
  2. Date components searches. This assumes there is a field reg_dt which is a datettime

    table: users
    where:
    	reg_dt_year = 2020
    	and reg_dt_month = 7
    	and reg_dt_day = 21
    

    date types supports the following suffixes: _year, _month, _day

    datetime types supports the suffixes listed above with _hour, _date and _tzname

  3. table: users distinct
    fields: name
    limit: 150
    
  4. table: grades expand
    fields: userid.firstname userid.surname grade
    order_by: userid.firstname
    where:
      userid.age > 20
      and userid.age < 50
    
  5. table: grades
    where:
      score < 90
      or id = 3
      and score > 60
    

    and joiners are resolved first before the or joiners.

  6. a where condition that contains space.

    table: grades
    where:
      score < 90
      and remark = 'not suspicious'
    
  7. in queries

    table: users
    where:
      id in 1 13 15 3
      and name in 'James John' 'John Paul' 'Paulo liv'
    
  8. isnull queries. To find fields which were not set.

    table: users
    where:
      age isnull
      and id > 300
    
  9. notnull queries. To find the fields which are set.

    table: users
    where:
      email notnull
    
  10. nin queries

    table: users
    where:
      id nin 1 3 32 42
    
  11. full text search (fts) queries

    table: users
    order_by: bio desc
    where:
      bio fts 'laptop man'
    
  12. fts searches support some symbols. + for compulsory and - for must not be present

< Previous Next >