diff --git a/Plugin-Examples.md b/Plugin-Examples.md new file mode 100644 index 0000000..c4281e8 --- /dev/null +++ b/Plugin-Examples.md @@ -0,0 +1,18 @@ + +## JavaScript Examples +### Meta Service +The Meta Service allows you to store your own key-value pairs in the EFMeta table under the database you are using. This is helpful when building a plugin that requires persistent data storage and retrieval. Each key-value pair is stored under a client ID. + +```js +this.manager = manager; +this.serviceResolver = _serviceResolver; + +// Resolve IMetaService to a variable +this.metaService = this.serviceResolver.ResolveService("IMetaService"); +// Get the owner of the data by client ID +var owner = this.manager.GetClientService().Get(clientID).Result +// Store some data under the owner +this.metaService.AddPersistentMeta("my_data", "My Data Value"), owner).Result +// Fetch a value by its key +var data = this.metaService.GetPersistentMeta("my_data", owner).Result.Value; +``` \ No newline at end of file