Make Driectory structure like google drive - node.js

Please help with with the database design for the directory table. I want to give option to users to create folder or subfolder and place their files in them or so on. I have seen the Microsoft installer directory table. But I think it will make complexities when I want to get data or structure with respect to usernames.

MongoDB structure:
{
"user": "Peter",
"drive": {
"folders": {
"MyExampleFolder": {
"files": [ FileUUID, FileUUID ]
"folders": [ FolderUUID ]
}
},
"files": { ... },
}
}
You'll store the folders and files inside "drive", then all the folders go inside "folder" (where inside that you have all the same "files" and "folders" (and so on).

Related

SuiteCommerce - show item inventory quantity on product page

I want to show the quantity available on the website's product page. I checked the web-store tab of the NetSuite item record but there seems no such field where I can populate this. Basically, I am trying to populate the stock's quantity available field.
Do I have to modify the code in tpl file for this? But the file is locked and there is read-only access to it.
The general process is to create a custom_modules folder at the same level as the project's SuiteCommerce folder and then tell the project about that folder by including it in the distro.json file and building and publishing the project
In the custom_modules folder you create a section folder (in my example named CustomItemViews#1.02)
and in that a Templates folder for your overrwritten template and also a ns.package.json where you tell SC about your overrides.
so in /custom_modules/CustomItemViews#1.02/ I have
ns.package.json
{
"gulp": {
"javascript": [
"JavaScript/*"
],
"sass": [
"Sass/*.scss"
],
"templates": [
"Templates/*"
]
}
,"overrides": {
"suitecommerce/ItemViews#1.0.2/Templates/item_views_stock.tpl": "Templates/item_views_stock.tpl",
}
}
and Templates/.
in /custom_modules/CustomItemViews#1.02/Templates I have, amongst other things not shown and paraphrased due to NS copyright,:
<p class="">
{{stockInfo.stock}}
</p>
final piece is the distro.json folder where all your custom modules are at
{
...
"modules":{
... maybe other custom modules
"custom_modules/CustomItemViews": "1.0.2",
... suitecommerce modules
}
}

Fail to give reference to another JSON schema

I am new in JSON schema and trying to validate my request with JSON schema. So i created schema. But i don't know why i am not able to give refrence to any another schema which located in same folder can any one help me to how to give $ref
{
"$id":"file:/schemas/ActionType",
"title":"ActionType",
"type":"object",
"properties":{
"ActionType":{
"enum":["fullLoad","update","insert","delete"]
}
},
"additionalProperties": false,
"required": ["ActionType"]
}
{
"$id":"file:/schemas/ERoaming",
"title":"ERoaming",
"type":"object",
"properties":{
"ActionType":{
"type":"object",
"$ref":"/schemas/ActionType.json"
}
},
"additionalProperties": false,
"required": ["ActionType"],
"$defs": {
}
}
I tried with without $id, relative path, path.
First of all, I don't think that's a valid file URI. It should look like file:///path/to/schemas/ActionType with three /s after the : and the full system path. You can't use a relative path.
Otherwise, everything looks fine with the schema. Another likely problem is that not all JSON Schema libraries understand files that reference the file system. You'll want to make sure the one you're using supports that feature.
When you're working with schemas in files, it's unnecessary to use $id. If the library properly handles file system references, the full path and filename should be automatically be used as the schema identifier. Then you can use relative references like I'm sure you're familiar with, { "$ref": "./ActionType.json" }.

Azure Logic Apps - Moving Email Message with Move Message action

I'm fairly new to Logic Apps and I have an app that I'm trying to get to move an email to a subfolder of the Inbox in a shared mailbox, but I'm trying to generate the path based on the date and I cannot for the life of me get it to work. I don't know if my path syntax is wrong or what.
The subfolder structure is basically
- Inbox
- 2018
- Jan
- Feb
- Mar
- Etc
And I'm trying to generate the path based off the year and the month using the Expressions part of a field. I've got an expression that generates the path for me
concat('Inbox\',formatDateTime(convertFromUtc(utcNow(),'Mountain Standard Time'),'MMM'),'\',formatDateTime(convertFromUtc(utcNow(),'Mountain Standard Time'),'yyyy'))
When the logic app runs this generates the correct path string of Inbox\2018\Jan but when the Move Email action runs it always escapes the backslash and then says it can't find the folder Inbox\\2018\\Jan.
So I either have this format wrong, I can't put the email in a subfolder or there's another way to do this.
I tried using the folder picker to pick one of the month subfolders and then peeked at the code and it uses some base64 encoded string for the path. I've pasted below what the peeked code shows
{
"inputs": {
"host": {
"connection": {
"name": "#parameters('$connections')['office365']['connectionId']"
}
},
"method": "post",
"path": "/Mail/Move/#{encodeURIComponent(triggerBody()?['Id'])}",
"queries": {
"folderPath": "Id::AAMkADRmOTgyMDI1LThkODYtNDMwYy1iYThiLTIzODQwN2Y1OGMzYQAuAAAAAAA6K3dJssnITb8NwkAsBOo7AQBaJ9ZTcg-MSoOEUUjjUdOAAAAD0nvYAAA="
},
"authentication": "#parameters('$authentication')"
},
"metadata": {
"Id::AAMkADRmOTgyMDI1LThkODYtNDMwYy1iYThiLTIzODQwN2Y1OGMzYQAuAAAAAAA6K3dJssnITb8NwkAsBOo7AQBaJ9ZTcg-MSoOEUUjjUdOAAAAD0nvYAAA=": "Jan"
}
}
Does anyone know how I would be able to move an email to a subfolder without using the folder picker?
Edit: Since posting I've also tried using the following strings that also do not work
Inbox/2018/Jan
Inbox:/2018/Jan
/Inbox/2018/Jan
You cant really have the path in terms of a hierarchy folder structure in this particular logic app.
If you look at the Documentation for Office 365 Mail rest operations #
https://msdn.microsoft.com/office/office365/api/mail-rest-operations#MoveCopyMessages
You will notice that to Move messages what you actually need is a folder ID. Also if you look at the logic app Designer, when you select a folder directly from there and then look at the code view you will see an ID. It looks something like
"method": "post",
"path": "/Mail/Move/#{encodeURIComponent(triggerBody()?['Id'])}",
"queries": {
"folderPath": "Id::AAMkADZmZDQ5OWNhLTU3NzQtNDRlZC1iMDRlLTg5NTA1NGM3NWJlZgAuAAAAAAAhZj7Qt8LySYhKvlgbXRNVAQBT8bGPBJK8Qqoy01hgwH4rAAEJysaQAAA="
}
},
"metadata": {
"Id::AAMkADZmZDQ5OWNhLTU3NzQtNDRlZC1iMDRlLTg5NTA1NGM3NWJlZgAuAAAAAAAhZj7Qt8LySYhKvlgbXRNVAQBT8bGPBJK8Qqoy01hgwH4rAAEJysaQAAA=": "Jan"
},
The FolderID is unique to every folder. One easy way to find the FolderIDs for a folder is to use
https://developer.microsoft.com/en-us/graph/graph-explorer#
and after signing in , posting
https://graph.microsoft.com/beta/me/mailFolders/Inbox/childFolders
as the query which will give you the ChildFolders for Inbox the values will look something like the following for every folder
"value": [
{
"id": "AAMkADZmZDQ5OWNhLTU3NzQtNDRlZC1iMDRlLTg5NTA1NGM3NWJlZgAuAAAAAAAhZj7Qt8LySYhKvlgbXRNVAQBT8bGPBJK8Qqoy01hgwH4rAAEJysWPAAA=",
"displayName": "AZCommunity",
"parentFolderId": "AAMkADZmZDQ5OWNhLTU3NzQtNDRlZC1iMDRlLTg5NTA1NGM3NWJlZgAuAAAAAAAhZj7Qt8LySYhKvlgbXRNVAQDX8XL9o4tkR5vF5sEdh44eAIYnQnhhAAA=",
"childFolderCount": 0,
"unreadItemCount": 5,
"totalItemCount": 169,
"wellKnownName": null
},
For what you are trying to do, you will have to do additional work to map the folders to the folder ID and then assign using that. I would suggest using Azure Functions to easily do this.

couchdb , procedure to add a CommonJS modules (show list function)

What is the exact procudure to add a CommonJs module on couchdb ?
I've read tutorials like:
https://caolan.org/posts/commonjs_modules_in_couchdb.html
from official doc:
http://docs.couchdb.org/en/1.6.1/query-server/javascript.html#commonjs-modules
The CommonJS module can be added to a design document, like so:
{
"views": {
"lib": {
"security": "function user_context(userctx, secobj) { ... }"
}
},
"validate_doc_update": "function(newdoc, olddoc, userctx, secobj) {
user = require('lib/security').user(userctx, secobj);
return user.is_admin();
}"
"_id": "_design/test"
}
but where I copy or paste that code? must I save to the file and add it with curl ? On fauxton i don'see where.
Managing CouchDB design documents is usually best accomplished via a tool like couchapp. It allows you to package up a directory of files and outputs a CouchDB design document.
You can manually edit that JSON in the futon/fauxton editor, but it's a pain and there are other tools out there depending on your toolchain. An external tool like this also aids in deployment, particularly across different environments.

Is there any way to retrieve the name for a gist that github displays

When I browse to a gist on gist.github.com it displays a friendly name. E.g. for
https://gist.github.com/stuartleeks/1f4e07546db69b15ade2 it shows stuartleeks/baz
This seems to be determined by the first file that it shows in the list of files for the gist, but I was wondering whether there is any way to retrieve this via the API?
Not directly, but you can get with the Gist API the JSON information associated to a gist, reusing the id of your url:
GET /gists/:id
In your case: https://api.github.com/gists/1f4e07546db69b15ade2
It includes:
"files": {
"baz": {
"filename": "baz",
and:
"owner": {
"login": "stuartleeks",
That should be enough to infer the name stuartleeks/baz.

Resources