Created Plugin Examples (markdown)
parent
18ccbcf1fd
commit
a0fcd7513e
18
Plugin-Examples.md
Normal file
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;
|
||||
```
|
Loading…
Reference in New Issue
Block a user