Store Manipulation
This Actor is unavailable because the developer has decided to deprecate it. Would you like to try a similar Actor instead?
See alternative ActorsStore Manipulation
Utility act to quickly copy or delete records in Key-value store.
store-manipulation
Apify utility act that allows you to manipulate records in key-value store. Currently it has those abilities:
- Copy records
- Delete records
- You can specify each record key yourself and/or use search patterns
- You can append a string to outputed record keys.
There are two main ways to get records that should be manipulated. You can combine both of those.
-
Add "keys" property to input. Act will get records under those keys. You can also add "inputPrefix" and/or "inputPostfix" properties, then act will find just your keys with those added strings. For more information, look at examples. Passing empty array or not passing those properties at all just skips this type of search.
-
Add "searchPrefix" and/or "searchPostfix" and/or "searchRegex" properties. Act will get all record keys starting and ending with those strings. If both are specified, act gets only record key that match both. Passing empty string or not passing those properties at all just skips this type of search.
INPUT
Input is an application/json
object with the following properties:
Be careful when deleting
1{ 2 // The only mandatory property. It is store id of store from which records will be manipulated (copied, deleted etc.). Passing non-existing id will throw an error. 3 inputStore: String, 4 5 // Property specifing if found records from input store will be deleted (after other actions are finished). Be very careful with your settings when setting this to true, double check everything. Default value is false. 6 delete: Maybe Boolean, 7 8 // Property specifing if found records from input store will be copied to output store. If copy is true and output store is not specified, act throws an error. Default value is false. 9 copy: Maybe Boolean, 10 11 // outputStore can be either store id or store name (only if it is on your account). If this propery doesn't match any id or name, act will create a store with given string and use it as output store. 12 outputStore: Maybe String, 13 14 // Array of string keys to specify which exact record keys you want to be manipulated. See also inputPrefix and inputPostfix properties. 15 keys: Maybe [String], 16 17 // If true, act gets all records from input store to be manipulated. Be very careful with this option. Default is false. 18 selectAll: Maybe Boolean, 19 20 // Content type of the records that will be copied to output store. Default is application/json. 21 contentType: Maybe String, 22 23 // If this string if provided, act will get all records starting with this string and manipulating with them. Empty string is the same as not using this option at all. 24 searchPrefix: Maybe String, 25 26 // If this string if provided, act will get all records ending with this string and manipulating with them. Empty string is the same as not using this option at all. 27 searchPostfix: Maybe String, 28 29 // If this string if provided, act will get all records matching this regular expression and manipulating with them. Empty string is the same as not using this option at all. Be careful that this regular expression is passed as string to a new RegExp constructor so you need to escape backslashes. 30 searchRegex: Maybe String, 31 32 // This option only works when specifing exact keys with "keys" array property. Act gets records from "keys" array that have this string inserted. 33 inputPrefix: Maybe String, 34 35 // This option only works when specifing exact keys with "keys" array property. Act gets records from "keys" array that have this string appended. 36 inputPostfix: Maybe String, 37 38 // When copying records to output store, you can specify this string that will be inserted to stored record key. 39 outputPrefix: Maybe String, 40 41 // When copying records to output store, you can specify this string that will be appended to stored record key. 42 outputPostfix: Maybe String 43}
Example input:
1{ 2"inputStore": "KP5XNqliR5FrG4zCy", 3"delete":true, 4"copy": true, 5"outputStore": "TEST-ACT", 6"keys": ["my-record", "my-other-record"], 7"selectAll": false, 8"contentType":"", 9"inputPrefix":"", 10"inputPostfix": "-data", 11"outputPrefix":"result-", 12"outputPostfix": "", 13"searchPrefix": "images-", 14"searchPostfix": "-urls", 15"searchRegex":"" 16}
This example act will first check if "inputStore" exists. Then it tries to find "outputStore" as id. Id is not found so it tries to find it by name, which is also not found so it creates store named "TEST-ACT" as sets it as outputStore. Then it searches keys "my-record-data" and "my-other-record-data", copies them to output store as "result-my-record" and "result-my-other-record". After records are copied, it deletes them from input store. Then it searches for every record key beggining with "images-" and ending with "-urls", for example "images-beach-urls", "images-hotel-urls" etc. and do the same with them as the first search.