0

I am using Crossrider API to develop a browser extension.

I want to add multiple values for same key in Crossrider local database,

The method that crossrider supports is appAPI.db.set

appAPI.db.set(key, value, [expires])

But I want to save many values like:

appAPI.db.set('a.html',5,10,300)

It takes one value as a parameter, how to store many values for the same key?

j0k
  • 22,600
  • 28
  • 79
  • 90
user2130649
  • 89
  • 1
  • 5

2 Answers2

2
appAPI.db.set( 'a.html', [5,10,30], [expires] )

then to retrieve it:

var myValues = appAPI.db.get('a.html');
Arno 2501
  • 8,921
  • 8
  • 37
  • 55
0

As mentioned by Arno2501, you can use appAPI.db.set and appAPI.db.get to work with the extension's local database. The appAPI.db API enables you to save your data in your preferred format. So you can either use the previously described array data, or save the values as a string, or object depending on your requirements. Additionally, you can specify how long you want the data to persist in your local database.

For example:

appAPI.db.set('key', ['a.html',5,10,300]); // Save data as an array
appAPI.db.set('key', ['a.html',5,10,300].join('&')); // OR as a string
appAPI.db.set('key', {'url':'a.html', 'values': [5,10,300]); // OR as an object

var keyValue = appAPI.db.get('key'); // keyValue contains the array, string, or object saved
Shlomo
  • 3,763
  • 11
  • 16