Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API8 - DataStore #2134

Merged
merged 1 commit into from
Jul 1, 2020
Merged

API8 - DataStore #2134

merged 1 commit into from
Jul 1, 2020

Conversation

Faithcaio
Copy link
Contributor

@Faithcaio Faithcaio commented Jun 28, 2020

SpongeAPI | SpongeCommon

Key<Value<String>> stringKey = Key.builder().key(CatalogKey.of("myplugin", "stringKey")).type(TypeTokens.STRING_VALUE_TOKEN).build();
DataQuery stringQuery = DataQuery.of("stringQuery");
DataStore.builder().key(stringKey, (view, value) -> view.set(stringQuery, value), view -> view.getString(stringQuery)).build(TypeTokens.ENTITY_TOKEN);
// Simplified
DataStore.of(stringKey, stringQuery, TypeTokens.ENTITY_TOKEN);

// for Collection/Map/Array
Key<ListValue<String>> stringListKey = Key.builder().key(CatalogKey.of("myplugin", "stringListKey")).type(TypeTokens.LIST_STRING_VALUE_TOKEN).build();
DataQuery stringListQuery = DataQuery.of("stringListQuery");
DataStore.builder().key(stringListKey, (view, value) -> view.set(stringListQuery, value), view -> view.getStringList(stringListQuery)).build(TypeTokens.ENTITY_TOKEN);

// multiple keys
DataStore.builder()
        .key(stringKey, stringQuery)
        .key(stringListKey, (view, value) -> view.set(stringListQuery, value), view -> view.getStringList(stringListQuery))
        .build(TypeTokens.ENTITY_TOKEN);

@Faithcaio Faithcaio added the api: 8 (u) version: 1.16 (unsupported since Oct 17th 2023) label Jun 28, 2020
@Faithcaio Faithcaio added this to the Revision 8.0 milestone Jun 28, 2020
@Faithcaio Faithcaio requested a review from gabizou as a code owner June 28, 2020 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: 8 (u) version: 1.16 (unsupported since Oct 17th 2023)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant