Created Plugin Examples (markdown)

Julian 2020-09-28 20:35:30 -04:00
parent 18ccbcf1fd
commit a0fcd7513e

18
Plugin-Examples.md Normal file

@ -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;
```