Adobe Campaign - Query multiple schemas - javascript

In Adobe campaign I have several (400+) schemas so I need to query all of them to see if they have recent data so that I will know what schemas need to monitor. To do this I will use the creation date on every schema. The problem is that I don't want to do it manually (go 1 by 1), is there a way to automate this and get all the schemas let's say using java script and then use a query with the creation date and pass a specific date ?

Though it is possible, you may avoid it and try to consider as #theopendle mention, a database level query.
Nevertheless, just use the Source schema (xtk:srcSchema) and you will have all the schemas listed. Then you can use that retrieved schema in your next "monitoring" process.

This answer assumes you are using Adobe Campaign Classic (on premise) not Standard (cloud versions):
As far as I know, there is no way to easily do this from within Campaign. However, all the schemas you can query using the Generic Query Editor or in a worflow correspond to tables in the Oracle database on which AC is based. If you connect to this database you can run regular Oracle SQL queries which gives you much more control.

Related

Data masking in MongoDB

We have a MongoDB database in a development environment. There are a lot of collections that contain names of people. What we want to do is the following:
mask the names in each collection, the fields need to be updated directly in the database, cannot run them through some external pipeline
once masked, it is ok if we are unable to retrieve the original names (so one-way masking)
every unique name should result in the same mask
the masking script can be run on the mongodb cli or a MongoDB gui like Studio3T
I was thinking of maybe using MD5 or SHA, but I am not sure if either is available to use directly in mongo operations like update or even in javascript without external libraries.
Also, since MD5 always produces the same hash, if someone were to get access to the document, since we will not be masking the field name, it would be fairly easy to feed typical names into the algorithm until the hash matches to figure out the name, but I think we may be able to live with this.
An alternative I was thinking of was, to loop through the unique names we have, and create a map from names to UUIDs. Then, go through each collection and use this map to update the names with the UUIDs. The problem with this is that we'll need to keep this mapping dictionary for when we receive additional documents for an existing person.

NodeJS/Mongoose - Logical separation of same schema + multi-tenancy

I have 2 requirements in my application:
I have multiple clients, which should be completely separated
Each client can have multiple subsidiaries that he should be able to switch between without re-authenticating but the data should be separated (e.g. all vendors in subsidiary 1 should not be shown in subsidiary 2)
As for the first requirement, I'm thinking of using a multi-tenancy architecture. That is, there will be one API instance, one frontend instance per customer and one database per customer. Each request from the frontend will include a tenant ID by which the API decides which database it needs to connect to / use. I would use mongoose's useDb method for this.
Question 1: is this method a good approach and/or are there any known drawbacks performance wise? I'm using this article as a reference.
As for the second requirement, I would need to somehow logically separate certain schemas. E.g., I have my mongoose vendorSchema. But I would need to somehow separate the entries per subsidiary. I could only imagine to add a field to each of these "shared schemas" e.g.
const vendorSchema = new mongoose.Schema({
/* other fields... */
subsidiary {
type: mongoose.Schema.Types.ObjectId,
ref: "Subsidiary",
required: true
}
})
and then having to use this a subsidiary in every request to the API to use in the mongoose query to find the right data. That seems like a bad architectural decision and an overhead though, and seems little scalable.
Question 2: Is there a better approach to achieve this logical separation as per subsidiary for every "shared" schema?
Thanks in advance for any help!
To maybe answer part of your question..
A multi tenant application is, well normal.. I honestly don't know of any web-app that would be single tenant, unless it's just a personal app.
With that said the architecture you have will work but as noted in my comments there is no need to have a separate DB for each users, this would be a bit overkill and is the reason why SQL or Mongo queries exist.
Performance wise, in general database servers are very performant, that's what they are designed for, but this will rely on many factors
Number of requests
size of requests
DB optimization
Query optimization
Resources of DB server
I'm sure there are many more I didn't list but you get the idea..
To your second question, yes you could add a 'Subsidiary' field, this would say be the subsidiary ID, so then when you query Mongo you use where subsidiar = 'id' this would then return only the items for said user...
From the standpoint of multiple request to mongo for each API call, yah you want to try and limit the number of calls each time but thats where caching comes in, using something like redis to store the responses for x minutes etc. Then the response is mainly handled by redis, but again this is going to depend a lot on the size of the responses and frequency etc.
But this actually leads into why I was asking about DB choices, Mongo works really well for frequently changing schemas with little to no relation to each other. We use Mongo for an a chat application and it works really well for that because it's more or less just a JSON store for us with simply querying for chats but the second you need to have data relate to each other it can start to get tricky and end up costing you more time and resources trying to hack around mongo to do the same task.
I would say it could be worth doing an exercise where you look at your current data structure, where it is today and where it might go in the future. If you can foresee having your data related in anyway in the future or maybe even crypto ( yes mongo does have this but its only in the enterprise version) then it may be something to look at.

Alternative to collection group query

I am trying to write a https cloud function which pulls out specific documents from my cloud firestore. The initial collection is 'Message', however then there are various different sub collections. The path for each document I am trying to view is the following Message/{UserId}/{ChatRoomId}/{UserId_1}. One variable under each UserId_1 is 'creationTime' and I am trying to query for specific documents that satisfy such creationTime. The problem is I don't know how to solve it as I was told this requires the use of collection group queries, which are currently not available in the firestore. Any alternative suggestion?
What I would be trying to achieve in the end is a comparison of each document's creationTime with the current timestamp.
Update: As of May, 2019, Cloud Firestore now supports collection group queries.
As you mentioned, it is not possible at the time of writing to query across collections (the so called "collection group queries" are apparently under development, however).
So the only possibility seems to be a modification of your data model.
You could, for example, duplicate your data and have a collection for each creationTime (probably a Timestamp), under which you have one document for each triplet {UserId}/{ChatRoomId}/{UserId_1}

Run Database Stored RegEx against DOM

I have a question about how to approach a certain scenario before I get halfway through it and figure out it was not the best option.
I work for a large company that has a team that creates tools for the team mates to use that aren’t official enterprise tools. We have no access to the database directly, just access to an internal server to store our files to run and be able to access the main site with javascript etc (same domain).
What I am working on is a tool that has a ton of options in it that allow you to select that I will call “data points” on a page.
There are things like “Account status, Balance, Name, Phone number, email etc” and have it save those to an excel sheet.
So you input account numbers, choose what you need and then using IE Objects it navigates to the page and scrapes data you request.
My question is as follows..
I want to make the scraping part pretty Dynamic in the way it works. I want to be able to add new datapoints on the fly.
My goal or idea is so store the regular expression needed to get the specific piece of data in the table with the “data point option”.
If I choose “Name” it knows the expression for name in the database to run again the DOM.
What would be the best way about creating that type of function in Javascript / Jquery?
I need to pass a Regex to a function, have it run against the DOM and then return the result.
I have a feeling that there will be things that require more than 1 step to get the information etc.
I am just trying to think of the best way to approach it without having to hardcode 200+ expressions into the file as the page may get updated and need to be changed.
Any ideas?
IRobotSoft scraper may be the tool you are looking for. Check this forum and see if questions are similar to what you are doing: http://irobotsoft.org/bb/YaBB.pl?board=newcomer. It is free.
What it uses is not regular expression but a language called HTQL, which may be more suitable for extracting web pages. It also supports regular expression, but not as the main language.
It organizes all your actions well with a visual interface, so you can dynamically compose actions or tasks for changing needs.

How to extract individual columns of data from a record in sqlite?

I am writing an extension for the gnome-shell. The javascript extension spawns a sql query and captures the output on standard output.
The result of the query produces records with 2 columns. I can't seem to extract each column of a record individually because the delimiter used, in this case a '|', can possibly occur in either of the columns which are strings themselves.
How do I go about achieving the same? I am new to this type of real programming(i.e, databases, gnome, javascript). My previous programming experiences have been limited to implementing algorithms taught in the course/textbooks.
I recognise that this problem would dissappear if there was a javascript/gnome interface to sqlite3 like the c/c++ interface. I could then extract each column in a record with ease.
Googling in search of such an interface did not help me. I searched for "javascript interface for sqlite" and "gnome interface for sqlite".
If you are using the sqlite3 command-line utility, you can use the .format command to specify other output formats. .separator and .headers might also come in handy. Run sqlite3 and enter .help for more details.

Categories

Resources