Unomi Node
1.0.1
1.0.1
  • Apache Unomi Node.js SDK
  • Contribute
  • API
    • Profile
      • Create
      • Delete
      • Get
      • Count
      • Existing Properties
      • All Properties
      • Sessions
      • Get by Single Property
      • Query
    • Rule
      • Create
      • Get
      • Get All
    • Segment
Powered by GitBook
On this page
  • Usage
  • Response
  • Valid Query Operators
  • Real World Example

Was this helpful?

  1. API
  2. Profile

Query

Query existing profiles

Usage

const params = {
  limit:        <int>,
  offset:       <int>,
  forceRefresh: <boolean>,
  operator:     <string>
}

const query = [
  {
    prop:     <string>,
    operator: <string>,
    value:    <string>
  }
]

unomi.profile.query(params, query);

Response

{
  "success": <boolean>,
  "status":  <int>,
  "data":    {
    "list": [<object>]
  }
}

Valid Query Operators

  • all

  • contains

  • endsWith

  • equals

  • exists

  • greaterThan

  • greaterThanOrEqualTo

  • in

  • isDay

  • isNotDay

  • lessThan

  • lessThanOrEqualTo

  • between

  • mathcesRegex

  • missing

  • notEquals

  • notIn

  • startsWith

Real World Example

const params = {
  limit:        10,
  offset:       0,
  forceRefresh: true,
  operator:     "and"
}

const query = [
  {
    prop:     "properties.firstName",
    operator: "equals",
    value:    "John"
  },
  {
    prop:     "properties.lastName",
    operator: "equals",
    value:    "Doe"
  }
]

async function getProfiles() {
  try {
    
    const { data: { list } } = await unomi.profile.query(params, query);
    
    list.forEach((profile) => {
      console.log(`Hello ${profile.properties.firstName}!`);
    });
    
  } catch (err) {
    console.error("An error occurred while getting profiles");
    console.error(err);
  }
}
PreviousGet by Single PropertyNextRule

Last updated 5 years ago

Was this helpful?