From a0fcd7513e89f85002f51e4521a5c482dd309bc4 Mon Sep 17 00:00:00 2001 From: Julian Date: Mon, 28 Sep 2020 20:35:30 -0400 Subject: [PATCH] Created Plugin Examples (markdown) --- Plugin-Examples.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Plugin-Examples.md 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