Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

How do you index strings longer than 32 characters? #1233

Answered by ra0x3
PaulZhemanov asked this question in Q&A
Discussion options

You must be logged in to vote

@PaulZhemanov We use the Charfield scalar for indexing strings.

type Person {
  id: ID!
  name: Charfield! # Can be up to 255 characters long
}

In your indexer handler you can convert SizedAsciiString (the SDK's string type) to indexer string types by just doing

mod my_module {
  fn my_handler(event: MyEvent) {
    // Assuming event.name is a str[32] defined in your contract 
    let p = Person::new(event.name.to_string());
  }
}

Let me know if this helps. Also gonna move this to a discussion :)

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@ra0x3
Comment options

@PaulZhemanov
Comment options

Answer selected by PaulZhemanov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1232 on August 09, 2023 13:28.