Formatting and layout of retrieved records

Hello everybody,
I’m not a programmer and I presume the frontend web application takes care of the formatting of the retrieved output.

In my situation, almost each record has different content and my question is:

How is the formatting of a document (record) done in the frontend if the contents are almost never the same from document-to-document?

I need to deal with stuff like:

Different point sizes
Superscripts / subscripts
Bold, italic, underline, strike through
Tabs, indents.

In a website you can tag the content ahead of time and work with CSS, but I don’t know how it works when
you’re retrieving records from a MongoDB database.

Can somebody let their light shine on this and explain whether it is at all possible, and if so, how?

The content in question here, are dictionary entries and glossary entries.

Thanks in advance for the feedback.

Regards,

Carel.

Hi @Carel_Schilp,

Can you share a bit more about your data and what you want your expected output to be?

I’ll make some guesses here. Perhaps you want the word to be bold and it’s definition to not be bold. So you could store the word and definition in separate fields in a document in the database. You could write a loop that pulls out each document. Inside of that loop, you could create the html/css for each word and definition.

If I may add.

MongoDB university has 4 courses that might be of interest. It is the M220 series of courses. You have different versions of the course for different languages; Java, JavaScript, Python and C#/.Net. They feature web front end. See https://university.mongodb.com/ for more details.

2 Likes

Hi Lauren,

After rereading your reply, the sentence below might be the key to my problem. I’ll need to investigate that more. Could you send me an example for me to get an idea of what that would look like. Thx. Carel.

Thanks Steeve,

I’ll look into them.

Regards,

Carel.

Hi Lauren,

Hope you’re feeling better. My data consists of terms and their meanings and of translations from one language into the other (dictionary). The problem with that, is there a high variability from entry to entry, so that it’s not possible to say this field needs to be bold and that field needs to be italic.

Ideally, I would like to be able to put tags in the text and then control the formatting and layout using CSS.

So I guess the first thing I would like to know whether it’s possible at all. I presume it’s not possible to store any formatting or layout info together with the text in MongoDB. As a kludge solution I could format each entry in a DTP program, make a screenshot of the entry and store it in the database as a picture. In that case, user would not be able to copy and paste text from the screen.

So at the moment I’m a bit at a loss because I’m not a programmer myself and therefore don’t know what is possible in C#, Blazor and MongoDB.

On the other hand, MongoDB is a document database and I can’t be the only person in the universe who needs to output database records with formatting and layout. Hope this helps. If not, let me know.
Thanks in advance for your feedback.

Great call @steevej on pointing to the MongoDB University courses! The courses are totally free and super high quality.

I don’t recommend storing screenshots as that presents accessibility challenges for people using screen readers. You want your text to be text.

If you wanted to store tags in your fields in MongoDB as strings, you could. However, my hunch is that this would create problems in the long term. You’ll have a lot more flexibility if you store just your data in the database and then add the formatting later.

Can you give an example of some data that needs to be displayed differently on a case by case basis?

I confirm the above with emphasis on this would create problems in the long term.

For html tags directly in MongoDB here it is:

> db.test.insertOne( { "title" : "<h1>This is a level 1 html header </h1>" } )
{
	"acknowledged" : true,
	"insertedId" : ObjectId("5fce748a37294c5306fd5cda")
}
> db.test.find()
{ "_id" : ObjectId("5fce748a37294c5306fd5cda"), "title" : "<h1>This is a level 1 html header </h1>" }
> 

1 Like

Yes, I’ll put a few examples together so you have a better idea. I’ll send them tomorrow.

Thanks for the reply Steeve,

I didn’t know it is possible to store HTML tags together with text in MongoDB fields.

Regards,

Carel.

Hi Lauren,

I’ve been rethinking the whole situation and it’s more complicated than I can explain here online.
So as soon as I can afford it, I’ll sit down with a MongoDB expert and a C# expert and discuss a solution.
I’m leaning towards putting the output of each record into a preformatted document. That way the search terms can be stored as text in MongoDB and I don’t have to let the retrieval program do any on-the-fly formatting. The data to be retrieved is static, like in a normal dictionary and I can let MongoDB do the searching and sorting. At a later stage, it may be possible to implement full text search using Atlas, but first I need to have an installed base of users before I add other functionality. So I won’t be sending you the examples and will put the project on hold until I have spoken face-to-face with a developer and Database expert. Thanks for your input and I’ll be in touch in the future again.

Regards,

Carel.

Sounds good. Have fun working on your project!

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.